ArduinoMega2560_SPI 1.0
Cargando...
Buscando...
Nada coincide
app_api.h
Ir a la documentación de este archivo.
1/*
2 * app_api.h
3 *
4 * Define the API for the user applications to call the bootloader.
5 * This file is used in the user application code only!
6 * User bootloader should include bootapi.h file only.
7
8 * NOTE to implementors:
9 * The app_api.h and bootapi.h files should be kept in sync (the jump table structure)
10 * but it is not good to have a single file as the app version will have some extra functions
11 * and the functions are actually different in app than in bootloader.
12 *
13 * Created on: 16. 3. 2017
14 * Author: jan dolinay
15 */
16
17#ifndef APP_API_H_
18#define APP_API_H_
19
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25
26/* Error codes */
27#define BOOT_OK (0) /* no error, success */
28#define BOOT_ERROR (1) /* unspecified error */
29#define BOOT_FUNCTION_INVALID (2) /* The function address in jump table was not valid */
30#define BOOT_VERSION_INVALID (3) /* The version of the jump table in bootloader does not match the version of this code */
31#define BOOT_ID_INVALID (4) /* The ID of the bootloader API does not match the ID expected by this code */
32
33
34#define BOOT_API_VERSION (2) /* Version of the API expected by this code. */
35 /* See the "ver" field in jump table struct avrdbgboot_jump_table_s in app_api.c */
36
37
38/* Helper functions */
39/**
40 * Must be called to initialize the API and verify that it is OK before
41 * using any other function of this API.
42 */
43uint8_t dboot_init_api(void);
44
45
46/* Bootloader API functions - the functions in the bootloader */
47
48/**
49 * Read the verison of the API.
50 * This is the value of the "ver" field in the jump table struct avrdbgboot_jump_table_s
51 * @param ver (out) - the version of the API
52 * @return BOOT_OK on success.
53 * */
54uint8_t dboot_get_api_version(uint8_t *ver);
55
56/**
57 * Read the version of the bootloader from bootloader memory.
58 * This is the version of the bootloader, not the version of the API.
59 * The bootloader verison is (AVRDBG_BOOT_VERSION_MAJOR << 8) | (AVRDBG_BOOT_VERSION_MINOR)
60 * as defined in bootapi.c
61 * @param ver (out) - the version of the bootloader
62 * @return BOOT_OK on success.
63 * */
64uint8_t dboot_get_version(uint16_t *ver);
65
66
67/**
68 * Toggle the on-board LED
69 * This is only available if AVR8_STUB_DEBUG is defined. If not defined,
70 * it just returns BOOT_VERSION_INVALID.
71 * @return BOOT_OK on success.
72 */
73uint8_t dboot_led_toggle(void);
74
75
76/**
77 * Initialize the pin for on-board LED (PB5)
78 * This is only available if AVR8_STUB_DEBUG is defined. If not defined,
79 * it just returns BOOT_VERSION_INVALID.
80 * @return BOOT_OK on success.
81 */
82uint8_t dboot_led_init(void);
83
84/**
85 * Write to program memory from RAM buffer.
86 * rom_addr - in words,
87 * sz - in bytes and must be multiple of two.
88 */
89uint8_t dboot_safe_pgm_write(const void *ram_addr, uint16_t rom_addr, uint16_t sz);
90
91/**
92 * Handle X load command from GDB that is load new application to memory
93 */
94uint8_t dboot_handle_xload(void);
95
96
97
98#ifdef __cplusplus
99}
100#endif
101
102
103#endif /* APP_API_H_ */
uint8_t dboot_get_api_version(uint8_t *ver)
uint8_t dboot_led_toggle(void)
uint8_t dboot_handle_xload(void)
uint8_t dboot_led_init(void)
uint8_t dboot_safe_pgm_write(const void *ram_addr, uint16_t rom_addr, uint16_t sz)
uint8_t dboot_get_version(uint16_t *ver)
uint8_t dboot_init_api(void)