The firmware consists of 3 parts:
The bootloader carries out different system initialization functions and module application upgrades. The MDK is the window of communication between the module application and the gateway. The communication between the module application and the gateway is facilitated by MDK APIs. The MDK also processes the message received from the application by invoking the callback functions.
Mainly, the following MDK APIs have been used in the ADPAQ projects:
unsigned char np_api_register()
: This API is used to register the command and the function. When the MDK receives a command/message, it calls the associated callback function.void np_api_setup()
: It consists of initial functions of the module application. For example, this API may contain a timer initialization functionvoid np_api_loop()
: It consists of the code which implements the module functionality.The ADuCM3029 Microcontroller has 256KB of Flash Memory, 32KB of Data SRAM and 32KB of Instruction SRAM. The memory map of the moduware framework is depicted in the current section. Inside the Flash Memory,
The 32KB Data SRAM is divided into 2 parts, 16KB for the Bootloader and 16KB for the MDK/Application.
As explained previously, MDK library provides an interface for application (firmware) running on ADuCM3029 to control Gateway through SPI commands. The Gateway on the other end, controls the Tile Application (explained in next section) running on smartphone through BLE (Bluetooth) interface.
The following API's must be implemented by Application:
extern void np_api_setup(void);
Runs once on module power-upextern void np_api_loop(void);
Non-command callback function -- runs several timesThe following API's can be optionally implemented by Application:
void np_api_start(void);
Runs when operation startsvoid np_api_stop(void);
Runs when operation stopsOther API's available for application:
void np_api_set_app_version(uint8_t major, uint8_t minor, uint8_t revision);
Let the user set their own app version (optional)uint8_t np_api_register(MDK_REGISTER_CMD *table, uint8_t size);
Register the user's command callback functionsuint8_t np_api_upload(uint16_t command, uint8_t *data, uint8_t length);
Send data to the last sourcevoid np_api_pm_automode_set(void);
Enable power management modevoid np_api_pm_automode_clear(void);
Disable power management modeuint8_t np_api_run_loop_once(void);
Run the loop again before sleeping (unnecessary for free running mode)This is the main application running on ADuCM3029. Below are the steps that will help you in writing your own application using MDK library. Please see resources section to download source code.
Guide to import the source code and setup library paths
np_api_loop()
. The continuous function will check any conditions set or poll any hardware via access to the functions created in the modules .c file mentioned in part 2.np_api_setup()
np_api_loop()
: continuous loop retrieving data and uploading that data to Nexpaq API (np_api_upload(0x2800,[data],size). The data sent is retrieved on the tile side based on the addresses specified (source 0x2800+).Project
→ Build Project
or press F7.Dev Module
project → properties
. C/C++ Build
→ Settings
→ Cross Core GCC ARM Embedded C Linker
→ Libraries
.arm-none-eabi-objcopy -O binary ${ProjName} ${ProjName}.bin
in the command of post build steps. Click on OK. imageClean Project
. This deletes old build files.
DAPLINK
. imageApply
and then on Debug
. Startup
tab in the same window as target tab, change “Set breakpoint at” option. (Example, reset_handler). imageDAPLINK
USB drive.DAPLINK
but will be shown as MAINTENANCE
. In this case, just disconnect the power cable from the modules and connect them back again.