29#define NILE_MCU_BOOT_ACK 0x79
30#define NILE_MCU_BOOT_NACK 0x1F
31#define NILE_MCU_BOOT_START 0x5A
32#define NILE_MCU_BOOT_GET 0x00
33#define NILE_MCU_BOOT_GET_VERSION 0x01
34#define NILE_MCU_BOOT_GET_ID 0x02
35#define NILE_MCU_BOOT_READ_MEMORY 0x11
36#define NILE_MCU_BOOT_JUMP 0x21
37#define NILE_MCU_BOOT_WRITE_MEMORY 0x31
38#define NILE_MCU_BOOT_ERASE_MEMORY 0x44
39#define NILE_MCU_BOOT_SPECIAL 0x50
40#define NILE_MCU_BOOT_EXT_SPECIAL 0x51
41#define NILE_MCU_BOOT_WRITE_LOCK 0x63
42#define NILE_MCU_BOOT_WRITE_UNLOCK 0x73
43#define NILE_MCU_BOOT_READ_LOCK 0x82
44#define NILE_MCU_BOOT_READ_UNLOCK 0x92
45#define NILE_MCU_BOOT_GET_CRC 0xA1
47#define NILE_MCU_BOOT_ERASE_ALL_SECTORS 0xFFFF
49#define NILE_MCU_BOOT_FLAG_SIZE 0x01
50#define NILE_MCU_BOOT_FLAG_CHECKSUM 0x02
52#define NILE_MCU_FLASH_START 0x08000000
53#define NILE_MCU_FLASH_PAGE_SIZE 2048
55#define NILE_MCU_NATIVE_CMD(cmd, arg) (((cmd) & 0x7F) | ((arg) << 7))
132#define NILE_MCU_NATIVE_ERROR_SPI -1
137#define NILE_MCU_NATIVE_ERROR_MCU -2
149 int16_t __nile_mcu_native_send_cmd_async(uint16_t cmd,
int buflen,
const void __far* buffer);
150 return __nile_mcu_native_send_cmd_async(cmd, buflen, buffer);
183 int16_t result; uint8_t bytes;
189 int16_t result, bytes;
235 int16_t result, bytes;
246#define nile_mcu_native_cdc_write_async_finish nile_mcu_native_recv_cmd_response_int16
249 int16_t result, bytes;
260#define nile_mcu_native_cdc_available_async_finish nile_mcu_native_recv_cmd_response_int16
uint8_t nile_mcu_boot_get_version(void)
Get the version of the SPI protocol used. More information is available in the Application Note AN428...
static int16_t nile_mcu_native_mcu_spi_set_speed_sync(uint8_t speed)
Tell the MCU to operate at a specific SPI speed.
int16_t nile_mcu_native_recv_cmd(void __far *buffer, uint16_t buflen)
Receive the response of a "native protocol" MCU command synchronously.
static int16_t nile_mcu_native_mcu_get_uuid_sync(void __far *buffer, uint16_t buflen)
uint16_t nile_mcu_boot_get_id(void)
Get the chip ID. More information is available in the Application Note AN4286.
bool nile_mcu_boot_send_data(const void __far *buffer, uint16_t len, uint8_t flags)
static int16_t nile_mcu_native_cdc_write_sync(const void __wf_cram *buffer, uint16_t buflen)
static int16_t nile_mcu_native_recv_cmd_response_uint8(void)
#define NILE_MCU_NATIVE_CMD(cmd, arg)
static int16_t nile_mcu_native_cdc_read_sync(void __far *buffer, uint16_t buflen)
bool nile_mcu_boot_read_memory(uint32_t address, void __far *buffer, uint16_t buflen)
Request bytes from the MCU's address space.
bool nile_mcu_reset(bool to_bootloader)
Reset the MCU.
static int16_t nile_mcu_native_recv_cmd_response_int16(void)
int16_t nile_mcu_native_recv_cmd_start(uint16_t resplen)
Start receiving the response of a "native protocol" MCU command asynchronously.
static int16_t nile_mcu_native_mcu_switch_mode(uint8_t mode)
Switch the mode in which the MCU is operating.
bool nile_mcu_boot_jump(uint32_t address)
Request that the MCU branch to a specific address in memory.
static int16_t nile_mcu_native_cdc_available_async_start(const void __wf_cram *buffer, uint16_t buflen)
@ NILE_MCU_NATIVE_MODE_STANDBY
MCU standby mode - will not respond to further SPI messages until reset.
@ NILE_MCU_NATIVE_MODE_RTC
RTC emulation mode.
@ NILE_MCU_NATIVE_MODE_CDC
CDC output-only mode.
@ NILE_MCU_NATIVE_MODE_EEPROM
EEPROM emulation mode.
@ NILE_MCU_NATIVE_MODE_CMD
Native command mode.
static int16_t nile_mcu_native_cdc_write_async_start(const void __wf_cram *buffer, uint16_t buflen)
static int16_t nile_mcu_native_cdc_available_sync(void)
bool nile_mcu_boot_send_cmd(uint8_t cmd)
static bool nile_mcu_boot_erase_all_memory(void)
Erase all of the MCU's flash memory.
bool nile_mcu_boot_write_memory(uint32_t address, const void __far *buffer, uint16_t buflen)
Write bytes to the MCU's address space (RAM or flash memory).
static int16_t nile_mcu_native_send_cmd(uint16_t cmd, const void __far *buffer, int buflen)
Send a "native protocol" MCU command asynchronously.
uint16_t nile_mcu_boot_recv_data(void __far *buffer, uint16_t buflen, uint8_t flags)
bool nile_mcu_boot_erase_memory(uint16_t sector_address, uint16_t sector_count)
Erase pages of the MCU's flash memory.
#define NILE_MCU_BOOT_ERASE_ALL_SECTORS
static int16_t nile_mcu_native_cdc_clear_sync(void)
bool nile_mcu_boot_wait_ack(void)
int16_t nile_mcu_native_recv_cmd_finish(void __far *buffer, uint16_t buflen)
Finish receiving the response of a "native protocol" MCU command.