[3] | 1 | #ifndef __MAIN_H__ |
---|
| 2 | #define __MAIN_H__ |
---|
| 3 | |
---|
| 4 | // Bootloader commands |
---|
| 5 | |
---|
| 6 | #define CMD_INIT 0x7F |
---|
| 7 | #define CMD_ACK 0x79 |
---|
| 8 | #define CMD_NACK 0x1F |
---|
| 9 | #define CMD_GET 0x00 |
---|
| 10 | #define CMD_GETID 0x02 |
---|
| 11 | #define CMD_GET_VER_RPS 0x01 |
---|
| 12 | #define CMD_READ_MEMORY 0x11 |
---|
| 13 | #define CMD_GO 0x21 |
---|
| 14 | #define CMD_WRITE_MEMORY 0x31 |
---|
| 15 | #define CMD_ERASE 0x43 |
---|
| 16 | #define CMD_EXT_ERASE 0x44 |
---|
| 17 | #define CMD_WRITE_PROTECT 0x63 |
---|
| 18 | #define CMD_WRITE_UNPROTECT 0x73 |
---|
| 19 | #define CMD_READOUT_PROTECT 0x82 |
---|
| 20 | #define CMD_READOUT_UNPROTECT 0x92 |
---|
| 21 | |
---|
| 22 | // Bootloader compartibility version number: 1.1 |
---|
| 23 | #define BOOTLOADER_VERSION 0x11 |
---|
| 24 | |
---|
| 25 | #define FLASH_PAGE_SIZE (2*1024) /*!< FLASH Page Size, 2 KBytes */ |
---|
| 26 | #define FLASH_PAGE_NUMBER 64 |
---|
| 27 | |
---|
| 28 | #define BOOTLOADER_PROGRAM_SIZE (12*1024) // 12K |
---|
| 29 | |
---|
| 30 | #define BOOTLOADER_LAST_PAGE ((BOOTLOADER_PROGRAM_SIZE/FLASH_PAGE_SIZE)-1) |
---|
| 31 | |
---|
| 32 | #define MAIN_APP_START_ADDRESS (FLASH_BASE + (FLASH_PAGE_SIZE * (BOOTLOADER_LAST_PAGE + 1))) |
---|
| 33 | #define MAIN_APP_PARAM_PAGE_NUM 2 // Amount of reserved pages at the end of the main program for storing some parameters |
---|
| 34 | |
---|
| 35 | #ifdef DEBUG |
---|
| 36 | #define BOOTLOADER_TIME_TO_WAIT 10000 // 10s |
---|
| 37 | #else |
---|
| 38 | #define BOOTLOADER_TIME_TO_WAIT 5000 // 5s |
---|
| 39 | #endif |
---|
| 40 | |
---|
| 41 | #define KEY1 0x45670123U |
---|
| 42 | #define KEY2 0xCDEF89ABU |
---|
| 43 | #define OPTKEY1 0x08192A3BU |
---|
| 44 | #define OPTKEY2 0x4C5D6E7FU |
---|
| 45 | |
---|
| 46 | #define BLUE_LED_PERIOD 75U |
---|
| 47 | #define BLUE_LED_PORT GPIOD |
---|
| 48 | #define RED_LED_PORT GPIOD |
---|
| 49 | #define BLUE_LED_PIN 2 |
---|
| 50 | #define RED_LED_PIN 3 |
---|
| 51 | |
---|
| 52 | #define UART USART1 |
---|
| 53 | #define UART_PORT GPIOA |
---|
| 54 | #define UART_RX_PIN 10 |
---|
| 55 | #define UART_TX_PIN 9 |
---|
| 56 | #define UART_TX_EN_PIN 12 |
---|
| 57 | #define UART_RX_ALT_FUNC_NUM 1 |
---|
| 58 | #define UART_TX_ALT_FUNC_NUM 1 |
---|
| 59 | #define UART_TXEN_ALT_FUNC_NUM 1 |
---|
| 60 | |
---|
| 61 | // Do not EDIT - START |
---|
| 62 | #define GPIOx_BSRR(mask, pin) PRE_GPIOx_BSRR(mask, pin) |
---|
| 63 | #define PRE_GPIOx_BSRR(mask, pin) mask##pin |
---|
| 64 | #define GPIOx_MODER(mask, pin) PRE_GPIOx_MODER(mask, pin) |
---|
| 65 | #define PRE_GPIOx_MODER(mask, pin) mask##pin |
---|
| 66 | #define GPIOx_MODER_Pos(mask, pin) PRE_GPIOx_MODER_Pos(mask, pin) |
---|
| 67 | #define PRE_GPIOx_MODER_Pos(mask, pin) mask##pin##_Pos |
---|
| 68 | #define GPIO_AFRH_AFSEL(mask, pin) PRE_GPIO_AFRH_AFSEL(mask, pin) |
---|
| 69 | #define PRE_GPIO_AFRH_AFSEL(mask, pin) mask##pin |
---|
| 70 | #define GPIO_AFRL_AFSEL(mask, pin) PRE_GPIO_AFRL_AFSEL(mask, pin) |
---|
| 71 | #define PRE_GPIO_AFRL_AFSEL(mask, pin) mask##pin |
---|
| 72 | #define GPIO_AFRH_AFSEL_Pos(mask, pin) PRE_GPIO_AFRH_AFSEL_Pos(mask, pin) |
---|
| 73 | #define PRE_GPIO_AFRH_AFSEL_Pos(mask, pin) mask##pin##_Pos |
---|
| 74 | #define GPIO_AFRL_AFSEL_Pos(mask, pin) PRE_GPIO_AFRL_AFSEL_Pos(mask, pin) |
---|
| 75 | #define PRE_GPIO_AFRL_AFSEL_Pos(mask, pin) mask##pin##_Pos |
---|
| 76 | #define GPIOx_PUPDR(mask, pin) PRE_GPIOx_PUPDR(mask, pin) |
---|
| 77 | #define PRE_GPIOx_PUPDR(mask, pin) mask##pin |
---|
| 78 | #define GPIOx_PUPDR_Pos(mask, pin) PRE_GPIOx_PUPDR_Pos(mask, pin) |
---|
| 79 | #define PRE_GPIOx_PUPDR_Pos(mask, pin) mask##pin##_Pos |
---|
| 80 | #define GPIOx_ODR(mask, pin) PRE_GPIOx_ODR(mask, pin) |
---|
| 81 | #define PRE_GPIOx_ODR(mask, pin) mask##pin |
---|
| 82 | #define GPIOx_BRR(mask, pin) PRE_GPIOx_BRR(mask, pin) |
---|
| 83 | #define PRE_GPIOx_BRR(mask, pin) mask##pin |
---|
| 84 | // Do not EDIT - END |
---|
| 85 | |
---|
| 86 | #define SWD_PORT GPIOA |
---|
| 87 | #define SWD_PIN_MSK GPIO_IDR_ID13 |
---|
| 88 | |
---|
| 89 | #define CRC_LEN 4 |
---|
| 90 | |
---|
| 91 | #endif |
---|