nRF52840 Support on MySensors



  • Re: Everything nRF52840

    Just wanting to find out if anyone @d00616 has the nRF52840 fully working with MySensors? I've been able to only get the radio part working, but the peripherals on the board (e.g. Adafruit Bluefruit Sense) don't seem to be exposed/working. I see adafruit have their own bootloader and way of programming this device, but it requires the upload of the softdevice, so we can't use it with Mysensors? Anyone got any workarounds to get it working?

    I created a new section for the nRF52840 in the \AppData\Local\Arduino15\packages\MySensors\hardware\nRF5\0.3.0\boards.txt.

    # MyBoardNRF5 nRF52840
    # Board definition is expected in
    # MyBoard.cpp and MyBoard.h as part
    # of the sketch
    ###################################
    
    MyBoard_nRF52840.name=MyBoardNRF5 nRF52840
    
    MyBoard_nRF52840.upload.tool=sandeepmistry:openocd
    MyBoard_nRF52840.upload.target=nrf52
    MyBoard_nRF52840.upload.maximum_size=524288
    
    MyBoard_nRF52840.bootloader.tool=sandeepmistry:openocd
    
    MyBoard_nRF52840.build.mcu=cortex-m4
    MyBoard_nRF52840.build.f_cpu=64000000
    MyBoard_nRF52840.build.board=GENERIC
    MyBoard_nRF52840.build.core=sandeepmistry:nRF5
    MyBoard_nRF52840.build.variant=MyBoardNRF5
    MyBoard_nRF52840.build.variant_system_lib=
    # -I{build.path} and -DMYBOARDNRF5 is only required by MyBoardNRF5
    MyBoard_nRF52840.build.extra_flags=-DNRF52840_XXAA -DMYBOARDNRF5 -I{build.path}
    MyBoard_nRF52840.build.float_flags=-mfloat-abi=hard -mfpu=fpv4-sp-d16
    MyBoard_nRF52840.build.ldscript=nrf52840_xxaa.ld
    
    MyBoard_nRF52840.menu.bootcode.none=None
    MyBoard_nRF52840.menu.bootcode.none.softdevice=none
    
    MyBoard_nRF52840.menu.lfclk.lfxo=Crystal Oscillator
    MyBoard_nRF52840.menu.lfclk.lfxo.build.lfclk_flags=-DUSE_LFXO
    MyBoard_nRF52840.menu.lfclk.lfrc=RC Oscillator
    MyBoard_nRF52840.menu.lfclk.lfrc.build.lfclk_flags=-DUSE_LFRC
    MyBoard_nRF52840.menu.lfclk.lfsynt=Synthesized
    MyBoard_nRF52840.menu.lfclk.lfsynt.build.lfclk_flags=-DUSE_LFSYNT
    
    MyBoard_nRF52840.menu.reset.notenable=Don't enable
    MyBoard_nRF52840.menu.reset.notenable.build.reset_flags=
    MyBoard_nRF52840.menu.reset.enabled=Enable
    MyBoard_nRF52840.menu.reset.enabled.build.reset_flags=-DCONFIG_GPIO_AS_PINRESET
    

    When compiling, it didn't like the reference to 250kbps speed, so I had to comment out references. Using current Dev branch...

    in \AppData\Local\Arduino15\packages\MySensors\hal\transport\NRF5_ESB\driver\Radio.h

    // Radio mode (Data rate)
    typedef enum {
    	NRF5_1MBPS = RADIO_MODE_MODE_Nrf_1Mbit,
    	NRF5_2MBPS = RADIO_MODE_MODE_Nrf_2Mbit,
    	//NRF5_250KBPS = RADIO_MODE_MODE_Nrf_250Kbit, // Deprecated!!!
    	NRF5_BLE_1MBPS = RADIO_MODE_MODE_Ble_1Mbit,
    } nrf5_mode_e;
    
    

    in \AppData\Local\Arduino15\packages\MySensors\hal\transport\NRF5_ESB\driver\Radio_ESB.cpp

    // Calculate time to transmit an byte in µs as bit shift -> 2^X
    static inline uint8_t NRF5_ESB_byte_time()
    {
    	if ((MY_NRF5_ESB_MODE == NRF5_1MBPS) or
    	        (MY_NRF5_ESB_MODE == NRF5_BLE_1MBPS)) {
    		return (3);
    	} else if (MY_NRF5_ESB_MODE == NRF5_2MBPS) {
    		return (2);
    	} //else if (MY_NRF5_ESB_MODE == NRF5_250KBPS) {
    		//return (5);
    	//}
    }
    

    I'm wondering if the memory definitions in sandeepmistry\hardware\nRF5\0.7.0\cores\nRF5\SDK\components\toolchain\gcc\nrf52840_xxaa.ld are correct/complete, and if they should be linking to nrf52_common.ld or what changes need made there? The memory map https://infocenter.nordicsemi.com/topic/ps_nrf52840/memory.html?cp=4_0_0_3_1 seems more complicated than the nRF52832, and difficult to read across, so I'm not sure if anything needs changed/updated there?

    For the pins, I see the standard MyBoard defintiion is for 32 pins on p0, but I see in the adafruit definitions they reference p1 pins, it seems that p0 covers pins 0 to 31 and p1 continues with references 32-63. To support referencing p1 pins, do we then just need to extend the pin definitions to 64 pins in \AppData\Local\Arduino15\packages\MySensors\hardware\nRF5\0.3.0\variants\MyBoardNRF5\compat_pin_mapping.h and add to the list in MyBoardNRF5.cpp and reference in MyBoard NRF5.h alongside the sketch?

    Would welcome any other insights or steer if anyone has got it working with MySensors?


Log in to reply
 

Suggested Topics

  • 3
  • 7
  • 9
  • 1
  • 5
  • 5
  • 4
  • 11

239
Online

9.9k
Users

10.5k
Topics

108.0k
Posts