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 Sense | LPC11U35 Interface CPU | コメント |
J3:Pin2 (ボード裏のパッド) | CN1:Pin3 P0_7 | SWDIO |
J3:Pin3 (ボード裏のパッド) | CN1:Pin4 P0_8 | SWCLK |
JP2:Pin14 GND | CN2:Pin1 GND | GND |
3)USBSerial
シリアル出力は、NANO 33 BLE SENSEボードのUSB端子経由で出力されます。
4)Mbed Studio 1.3.1を使って開発のこと!(オンラインコンパイラでは動作しません!)
5)ボードピン配置
3_check_LPS22HB/main3.cpp@0:f1a10797d9f6, 2020-02-07 (annotated)
- Committer:
- kenjiArai
- Date:
- Fri Feb 07 01:21:16 2020 +0000
- Revision:
- 0:f1a10797d9f6
- Child:
- 1:cce280da16d4
only test purpose not official
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kenjiArai | 0:f1a10797d9f6 | 1 | /* |
kenjiArai | 0:f1a10797d9f6 | 2 | * Mbed Application program |
kenjiArai | 0:f1a10797d9f6 | 3 | * Nano 33 BLE Sense board runs on mbed-OS5 |
kenjiArai | 0:f1a10797d9f6 | 4 | * LPS33HB -> MEMS nano pressure sensor: |
kenjiArai | 0:f1a10797d9f6 | 5 | * 260-1260 hPa absolute Digital output barometer |
kenjiArai | 0:f1a10797d9f6 | 6 | * by STMicroelectronics |
kenjiArai | 0:f1a10797d9f6 | 7 | * |
kenjiArai | 0:f1a10797d9f6 | 8 | * Copyright (c) 2020 Kenji Arai / JH1PJL |
kenjiArai | 0:f1a10797d9f6 | 9 | * http://www7b.biglobe.ne.jp/~kenjia/ |
kenjiArai | 0:f1a10797d9f6 | 10 | * https://os.mbed.com/users/kenjiArai/ |
kenjiArai | 0:f1a10797d9f6 | 11 | * Started: January 22nd, 2020 |
kenjiArai | 0:f1a10797d9f6 | 12 | * Revised: Feburary 5th, 2020 |
kenjiArai | 0:f1a10797d9f6 | 13 | */ |
kenjiArai | 0:f1a10797d9f6 | 14 | |
kenjiArai | 0:f1a10797d9f6 | 15 | // Pre-selection -------------------------------------------------------------- |
kenjiArai | 0:f1a10797d9f6 | 16 | #include "select_example.h" |
kenjiArai | 0:f1a10797d9f6 | 17 | //#define EXAMPLE_3_CHECK_LPS22HB |
kenjiArai | 0:f1a10797d9f6 | 18 | #ifdef EXAMPLE_3_CHECK_LPS22HB |
kenjiArai | 0:f1a10797d9f6 | 19 | |
kenjiArai | 0:f1a10797d9f6 | 20 | // Include -------------------------------------------------------------------- |
kenjiArai | 0:f1a10797d9f6 | 21 | #include "mbed.h" |
kenjiArai | 0:f1a10797d9f6 | 22 | #include "nano33blesense_iodef.h" |
kenjiArai | 0:f1a10797d9f6 | 23 | #include "LPS22HB.h" |
kenjiArai | 0:f1a10797d9f6 | 24 | |
kenjiArai | 0:f1a10797d9f6 | 25 | // Definition ----------------------------------------------------------------- |
kenjiArai | 0:f1a10797d9f6 | 26 | |
kenjiArai | 0:f1a10797d9f6 | 27 | // Constructor ---------------------------------------------------------------- |
kenjiArai | 0:f1a10797d9f6 | 28 | RawSerial pc(STDIO_UART_TX, STDIO_UART_RX, 115200); |
kenjiArai | 0:f1a10797d9f6 | 29 | DigitalOut sen_pwr(PIN_VDD_ENV, 1); |
kenjiArai | 0:f1a10797d9f6 | 30 | DigitalOut i2c_pullup(PIN_I2C_PULLUP, 1); |
kenjiArai | 0:f1a10797d9f6 | 31 | I2C i2c(PIN_SDA1, PIN_SCL1); |
kenjiArai | 0:f1a10797d9f6 | 32 | LPS22HB *baro = NULL; |
kenjiArai | 0:f1a10797d9f6 | 33 | Timer t; |
kenjiArai | 0:f1a10797d9f6 | 34 | |
kenjiArai | 0:f1a10797d9f6 | 35 | // RAM ------------------------------------------------------------------------ |
kenjiArai | 0:f1a10797d9f6 | 36 | |
kenjiArai | 0:f1a10797d9f6 | 37 | // ROM / Constant data -------------------------------------------------------- |
kenjiArai | 0:f1a10797d9f6 | 38 | |
kenjiArai | 0:f1a10797d9f6 | 39 | // Function prototypes -------------------------------------------------------- |
kenjiArai | 0:f1a10797d9f6 | 40 | extern void check_i2c_connected_devices(void); |
kenjiArai | 0:f1a10797d9f6 | 41 | |
kenjiArai | 0:f1a10797d9f6 | 42 | //------------------------------------------------------------------------------ |
kenjiArai | 0:f1a10797d9f6 | 43 | // Control Program |
kenjiArai | 0:f1a10797d9f6 | 44 | //------------------------------------------------------------------------------ |
kenjiArai | 0:f1a10797d9f6 | 45 | int main() |
kenjiArai | 0:f1a10797d9f6 | 46 | { |
kenjiArai | 0:f1a10797d9f6 | 47 | i2c_pullup = 1; |
kenjiArai | 0:f1a10797d9f6 | 48 | sen_pwr = 1; |
kenjiArai | 0:f1a10797d9f6 | 49 | pc.printf("\r\nCheck LSM9DS1\r\n"); |
kenjiArai | 0:f1a10797d9f6 | 50 | thread_sleep_for(200); |
kenjiArai | 0:f1a10797d9f6 | 51 | // check I2C line |
kenjiArai | 0:f1a10797d9f6 | 52 | check_i2c_connected_devices(); |
kenjiArai | 0:f1a10797d9f6 | 53 | baro = new LPS22HB(i2c, LPS22HB_G_CHIP_ADDR); |
kenjiArai | 0:f1a10797d9f6 | 54 | uint8_t id = baro->read_id(); |
kenjiArai | 0:f1a10797d9f6 | 55 | if (id == I_AM_LPS22HB) { |
kenjiArai | 0:f1a10797d9f6 | 56 | pc.printf("LPS22H is ready. ID = 0x%x\r\n", id); |
kenjiArai | 0:f1a10797d9f6 | 57 | } else { |
kenjiArai | 0:f1a10797d9f6 | 58 | pc.printf("LPS22H is NOT ready. return value = 0x%x\r\n", id); |
kenjiArai | 0:f1a10797d9f6 | 59 | } |
kenjiArai | 0:f1a10797d9f6 | 60 | baro->set_odr(); |
kenjiArai | 0:f1a10797d9f6 | 61 | uint32_t n = 0; |
kenjiArai | 0:f1a10797d9f6 | 62 | while(true) { |
kenjiArai | 0:f1a10797d9f6 | 63 | t.reset(); |
kenjiArai | 0:f1a10797d9f6 | 64 | t.start(); |
kenjiArai | 0:f1a10797d9f6 | 65 | baro->get(); |
kenjiArai | 0:f1a10797d9f6 | 66 | while (baro->data_ready() == 0){ |
kenjiArai | 0:f1a10797d9f6 | 67 | thread_sleep_for(2); |
kenjiArai | 0:f1a10797d9f6 | 68 | } |
kenjiArai | 0:f1a10797d9f6 | 69 | pc.printf("Pressure: %6.1f [hPa], Temperature: %+4.1f [degC], ", |
kenjiArai | 0:f1a10797d9f6 | 70 | baro->pressure(), baro->temperature()); |
kenjiArai | 0:f1a10797d9f6 | 71 | ++n; |
kenjiArai | 0:f1a10797d9f6 | 72 | uint32_t passed_time = t.read_ms(); |
kenjiArai | 0:f1a10797d9f6 | 73 | pc.printf("processing time: %d [ms], count: %4d\r\n", passed_time, n); |
kenjiArai | 0:f1a10797d9f6 | 74 | if (passed_time < 999){ |
kenjiArai | 0:f1a10797d9f6 | 75 | thread_sleep_for(1000 - t.read_ms()); |
kenjiArai | 0:f1a10797d9f6 | 76 | } |
kenjiArai | 0:f1a10797d9f6 | 77 | } |
kenjiArai | 0:f1a10797d9f6 | 78 | } |
kenjiArai | 0:f1a10797d9f6 | 79 | |
kenjiArai | 0:f1a10797d9f6 | 80 | #endif // EXAMPLE_3_CHECK_LPS22HB |