Arduino board run on Mbed-os6.8.1 (only test purpose not official). Need Mbed Studio(1.3.1) not online compiler. If you compile on the online compiler, you can get a hex file but it does NOT work!!!

Dependencies:   APDS_9960 LPS22HB LSM9DS1 HTS221

1) DAPLink(LPC11U35)の準備
使用したボード →https://akizukidenshi.com/catalog/g/gK-12144/
プログラムは、nRF52840-MDK用に公開されているDAPLinkのコンパイル済のバイナリコードを使わせていただきました。
https://github.com/makerdiary/nrf52840-mdk/tree/master/firmware/daplink
LPC11U35への書込みは、SW1(ISP)を押したままSW2(RESET)を操作するとPCに「CRP DISABLD」という名称でマウントされるので、書込まれているfirmware.binを削除してから、上記のbinファイルをコピーすれば書き込みが行われます。
書込み完了後にSW1を押さずに起動すれば、「DAPLINK」として認識されます。
DETAILS.TXTでDAPLinkの内容を確認できます。

2) 接続

Arduino Nano 33 BLE SenseLPC11U35 Interface CPUコメント
J3:Pin2 (ボード裏のパッド)CN1:Pin3 P0_7SWDIO
J3:Pin3 (ボード裏のパッド)CN1:Pin4 P0_8SWCLK
JP2:Pin14  GNDCN2:Pin1 GNDGND

https://os.mbed.com/media/uploads/kenjiArai/snano_daplink.jpg https://os.mbed.com/media/uploads/kenjiArai/snano33ble_bottom.jpg
3)USBSerial
シリアル出力は、NANO 33 BLE SENSEボードのUSB端子経由で出力されます。

4)Mbed Studio 1.3.1を使って開発のこと!(オンラインコンパイラでは動作しません!)
https://os.mbed.com/media/uploads/kenjiArai/s1_2020-02-13.png https://os.mbed.com/media/uploads/kenjiArai/s2_2020-02-13.png

5)ボードピン配置 https://os.mbed.com/media/uploads/kenjiArai/nano33ble_pin.png

Committer:
kenjiArai
Date:
Sun Feb 28 07:31:58 2021 +0000
Revision:
1:cce280da16d4
Parent:
0:f1a10797d9f6
run on mbed-os6.8.0 (compile on Mbed Studio 1.3.1)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenjiArai 0:f1a10797d9f6 1 /*
kenjiArai 0:f1a10797d9f6 2 * APDS-9960
kenjiArai 0:f1a10797d9f6 3 * Digital Proximity, Ambient Light, RGB and Gesture Sensor
kenjiArai 0:f1a10797d9f6 4 *
kenjiArai 1:cce280da16d4 5 * Mbed Application program
kenjiArai 1:cce280da16d4 6 * Nano 33 BLE Sense board runs on mbed-OS6
kenjiArai 0:f1a10797d9f6 7 * Modified by Kenji Arai / JH1PJL
kenjiArai 0:f1a10797d9f6 8 * http://www7b.biglobe.ne.jp/~kenjia/
kenjiArai 0:f1a10797d9f6 9 * https://os.mbed.com/users/kenjiArai/
kenjiArai 1:cce280da16d4 10 * Started: February 2nd, 2020
kenjiArai 1:cce280da16d4 11 * Revised: February 28th, 2021
kenjiArai 0:f1a10797d9f6 12 *
kenjiArai 0:f1a10797d9f6 13 * Original:
kenjiArai 0:f1a10797d9f6 14 * https://os.mbed.com/users/kbhagat6/code/Gesture_User_Interface/
kenjiArai 0:f1a10797d9f6 15 */
kenjiArai 0:f1a10797d9f6 16
kenjiArai 0:f1a10797d9f6 17 // Pre-selection --------------------------------------------------------------
kenjiArai 0:f1a10797d9f6 18 #include "select_example.h"
kenjiArai 0:f1a10797d9f6 19 //#define EXAMPLE_6_CHECK_APDS_9960
kenjiArai 0:f1a10797d9f6 20 #ifdef EXAMPLE_6_CHECK_APDS_9960
kenjiArai 0:f1a10797d9f6 21
kenjiArai 0:f1a10797d9f6 22 // Include --------------------------------------------------------------------
kenjiArai 0:f1a10797d9f6 23 #include "mbed.h"
kenjiArai 0:f1a10797d9f6 24 #include "nano33blesense_iodef.h"
kenjiArai 0:f1a10797d9f6 25 #include "glibr.h"
kenjiArai 0:f1a10797d9f6 26
kenjiArai 0:f1a10797d9f6 27 // Definition -----------------------------------------------------------------
kenjiArai 0:f1a10797d9f6 28
kenjiArai 0:f1a10797d9f6 29 // Object ---------------------------------------------------------------------
kenjiArai 1:cce280da16d4 30 InterruptIn apds_int(PIN_APDS_INT);
kenjiArai 0:f1a10797d9f6 31 DigitalOut sen_pwr(PIN_VDD_ENV, 1);
kenjiArai 0:f1a10797d9f6 32 DigitalOut i2c_pullup(PIN_I2C_PULLUP, 1);
kenjiArai 0:f1a10797d9f6 33 DigitalOut led_y(PIN_YELLOW, 0);
kenjiArai 0:f1a10797d9f6 34 DigitalOut led_g(PIN_GREEN, 0);
kenjiArai 0:f1a10797d9f6 35 DigitalOut lr(PIN_LR, 1);
kenjiArai 0:f1a10797d9f6 36 DigitalOut lg(PIN_LG, 1);
kenjiArai 0:f1a10797d9f6 37 DigitalOut lb(PIN_LB, 1);
kenjiArai 0:f1a10797d9f6 38 I2C i2c(PIN_SDA1, PIN_SCL1);
kenjiArai 0:f1a10797d9f6 39 glibr *gesture = NULL;
kenjiArai 0:f1a10797d9f6 40
kenjiArai 0:f1a10797d9f6 41 // ROM / Constant data --------------------------------------------------------
kenjiArai 0:f1a10797d9f6 42
kenjiArai 0:f1a10797d9f6 43 // RAM ------------------------------------------------------------------------
kenjiArai 0:f1a10797d9f6 44
kenjiArai 0:f1a10797d9f6 45 // Function prototypes --------------------------------------------------------
kenjiArai 0:f1a10797d9f6 46 void apds_hit_callback (void);
kenjiArai 0:f1a10797d9f6 47
kenjiArai 1:cce280da16d4 48 // subroutin (must be at this below line and do NOT change order) -------------
kenjiArai 1:cce280da16d4 49 #include "usb_serial_as_stdio.h"
kenjiArai 1:cce280da16d4 50 #include "check_revision.h"
kenjiArai 1:cce280da16d4 51 #include "common.h"
kenjiArai 1:cce280da16d4 52
kenjiArai 0:f1a10797d9f6 53 //------------------------------------------------------------------------------
kenjiArai 0:f1a10797d9f6 54 // Control Program
kenjiArai 0:f1a10797d9f6 55 //------------------------------------------------------------------------------
kenjiArai 0:f1a10797d9f6 56 int main()
kenjiArai 0:f1a10797d9f6 57 {
kenjiArai 0:f1a10797d9f6 58 bool gerror = false;
kenjiArai 0:f1a10797d9f6 59
kenjiArai 1:cce280da16d4 60 usb_serial_initialize();
kenjiArai 1:cce280da16d4 61 print_revision();
kenjiArai 0:f1a10797d9f6 62 i2c_pullup = 1;
kenjiArai 0:f1a10797d9f6 63 sen_pwr = 1;
kenjiArai 1:cce280da16d4 64 print_usb("Check APDS_9960\r\n");
kenjiArai 1:cce280da16d4 65 ThisThread::sleep_for(200ms);
kenjiArai 0:f1a10797d9f6 66 // check I2C line
kenjiArai 0:f1a10797d9f6 67 check_i2c_connected_devices();
kenjiArai 0:f1a10797d9f6 68 gesture = new glibr(PIN_SDA1, PIN_SCL1);
kenjiArai 0:f1a10797d9f6 69 if (gesture->ginit()) {
kenjiArai 1:cce280da16d4 70 print_usb("APDS-9960 initialization complete\n\r");
kenjiArai 0:f1a10797d9f6 71 } else {
kenjiArai 1:cce280da16d4 72 print_usb("Something went wrong during APDS-9960 init\n\r");
kenjiArai 0:f1a10797d9f6 73 gerror=true;
kenjiArai 0:f1a10797d9f6 74 }
kenjiArai 0:f1a10797d9f6 75 // Start running the APDS-9960 gesture sensor engine
kenjiArai 0:f1a10797d9f6 76 if ( gesture->enableGestureSensor(true) ) {
kenjiArai 1:cce280da16d4 77 print_usb("Gesture sensor is now running\n\r");
kenjiArai 0:f1a10797d9f6 78 } else {
kenjiArai 1:cce280da16d4 79 print_usb("Something went wrong during gesture sensor init!\n\r");
kenjiArai 0:f1a10797d9f6 80 gerror=true;
kenjiArai 0:f1a10797d9f6 81 }
kenjiArai 1:cce280da16d4 82 // set pullup for Interrupt input pin
kenjiArai 0:f1a10797d9f6 83 apds_int.mode(PullUp);
kenjiArai 0:f1a10797d9f6 84 // Delay for initial pullup to take effect
kenjiArai 1:cce280da16d4 85 ThisThread::sleep_for(1ms);
kenjiArai 0:f1a10797d9f6 86 // Setup Interrupt callback function for a pb hit
kenjiArai 1:cce280da16d4 87 apds_int.fall(&apds_hit_callback);
kenjiArai 1:cce280da16d4 88 // Enable interrut
kenjiArai 1:cce280da16d4 89 apds_int.enable_irq();
kenjiArai 0:f1a10797d9f6 90 while(!(gesture->isGestureAvailable())){
kenjiArai 1:cce280da16d4 91 ThisThread::sleep_for(200ms);
kenjiArai 0:f1a10797d9f6 92 }
kenjiArai 0:f1a10797d9f6 93 int temp;
kenjiArai 0:f1a10797d9f6 94 while(gerror == false) {
kenjiArai 0:f1a10797d9f6 95 if (gesture->isGestureAvailable()) {
kenjiArai 0:f1a10797d9f6 96 if(gesture->isGestureAvailable()){
kenjiArai 0:f1a10797d9f6 97 temp = gesture->readGesture();
kenjiArai 0:f1a10797d9f6 98 }
kenjiArai 0:f1a10797d9f6 99 switch ( temp) {
kenjiArai 0:f1a10797d9f6 100 case DIR_UP:
kenjiArai 1:cce280da16d4 101 print_usb("Forward\r\n");
kenjiArai 0:f1a10797d9f6 102 break;
kenjiArai 0:f1a10797d9f6 103 case DIR_DOWN:
kenjiArai 1:cce280da16d4 104 print_usb("Backward\r\n");
kenjiArai 0:f1a10797d9f6 105 break;
kenjiArai 0:f1a10797d9f6 106 case DIR_LEFT:
kenjiArai 1:cce280da16d4 107 print_usb("LEFT\r\n");
kenjiArai 0:f1a10797d9f6 108 break;
kenjiArai 0:f1a10797d9f6 109 case DIR_RIGHT:
kenjiArai 1:cce280da16d4 110 print_usb("RIGHT\r\n");
kenjiArai 0:f1a10797d9f6 111 break;
kenjiArai 0:f1a10797d9f6 112 case 67:
kenjiArai 1:cce280da16d4 113 print_usb("Collision\r\n");
kenjiArai 0:f1a10797d9f6 114 break;
kenjiArai 0:f1a10797d9f6 115 case DIR_NEAR:
kenjiArai 1:cce280da16d4 116 print_usb("NEAR\r\n");
kenjiArai 0:f1a10797d9f6 117 break;
kenjiArai 0:f1a10797d9f6 118 case DIR_FAR:
kenjiArai 1:cce280da16d4 119 print_usb("FAR\r\n");
kenjiArai 0:f1a10797d9f6 120 break;
kenjiArai 0:f1a10797d9f6 121 default:
kenjiArai 1:cce280da16d4 122 print_usb("NONE\r\n");
kenjiArai 0:f1a10797d9f6 123 break;
kenjiArai 0:f1a10797d9f6 124 }
kenjiArai 0:f1a10797d9f6 125 }
kenjiArai 0:f1a10797d9f6 126 }
kenjiArai 0:f1a10797d9f6 127 }
kenjiArai 0:f1a10797d9f6 128
kenjiArai 0:f1a10797d9f6 129 void apds_hit_callback (void)
kenjiArai 0:f1a10797d9f6 130 {
kenjiArai 0:f1a10797d9f6 131 led_y =!led_y;
kenjiArai 0:f1a10797d9f6 132 }
kenjiArai 0:f1a10797d9f6 133
kenjiArai 1:cce280da16d4 134 #endif // EXAMPLE_6_CHECK_APDS_9960