b23e62a3013c84c1cb45ddd418400452491219c0
Board-dat/NBL/NBL1064-dat/NBL1064-dat.md
| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | |
| 23 | -on board chip [[STM8-dat]] - [[MCU-dat]] - [[STM8-SDK-dat]] |
|
| 23 | +on board chip [[STM8-dat]] - [[MCU-dat]] - demo code find at [[STM8-SDK-dat]] |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | ### Board V2 |
SDK-dat/STM32-SDK-dat/STM32-SDK-dat.md
| ... | ... | @@ -2,9 +2,7 @@ |
| 2 | 2 | # STM32-SDK-dat.md |
| 3 | 3 | |
| 4 | 4 | |
| 5 | -- [[STM32-Cube-programmer-dat]] - [[ST-link-dat]] |
|
| 6 | - |
|
| 7 | -- [[STM8-SDK-dat]] - [[STM32-SDK-dat]] |
|
| 5 | +- [[STM32-Cube-programmer-dat]] - [[STM32-SDK-dat]] - [[STM8-SDK-dat]] - [[ST-LINK-dat]] - [[SDK-dat]] |
|
| 8 | 6 | |
| 9 | 7 | |
| 10 | 8 |
SDK-dat/STM8-SDK-dat/STM8-SDK-dat.md
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | # STM8-SDK-dat |
| 3 | 3 | |
| 4 | 4 | |
| 5 | -- [[STM8-SDK-dat]] - [[STM32-SDK-dat]] |
|
| 5 | +- [[STM32-Cube-programmer-dat]] - [[STM32-SDK-dat]] - [[STM8-SDK-dat]] - [[ST-LINK-dat]] - [[SDK-dat]] |
|
| 6 | 6 | |
| 7 | 7 | |
| 8 | 8 | - [[SWIM-dat]] - 18 PD1 (HS)/`SWIM` - [[SDK-dat]] - [[ST-dat]] - [[STM8-SDK-dat]] |
| ... | ... | @@ -45,6 +45,15 @@ Guide for IAR STM8 |
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | |
| 48 | +## boards |
|
| 49 | + |
|
| 50 | +- [[NBL1064-dat]] |
|
| 51 | + |
|
| 52 | + |
|
| 53 | +## apps and demo code |
|
| 54 | + |
|
| 55 | +- [[serial-foward.c]] == [[NBL1064-dat]] |
|
| 56 | + |
|
| 48 | 57 | ## repo |
| 49 | 58 | |
| 50 | 59 | https://github.com/btc520/STM8-APP |
SDK-dat/STM8-SDK-dat/serial-foward.c
| ... | ... | @@ -0,0 +1,138 @@ |
| 1 | +/* |
|
| 2 | + * Usage summary: |
|
| 3 | + * - UART1 TX: PD5 |
|
| 4 | + * - UART1 RX: PD6 |
|
| 5 | + * - Send "555" over the serial port to receive "OK555" and blink PB5 three times. |
|
| 6 | + * - Send "444" over the serial port to receive "OK444" and blink PB4 three times. |
|
| 7 | + * - Blink timing is 1 second ON, 1 second OFF for each of the three blinks. |
|
| 8 | + */ |
|
| 9 | + |
|
| 10 | +#include "stm8s.h" |
|
| 11 | + |
|
| 12 | +#define UART_BAUDRATE 9600UL |
|
| 13 | +#define BLINK_COUNT 3U |
|
| 14 | + |
|
| 15 | +static void clock_init(void); |
|
| 16 | +static void gpio_init(void); |
|
| 17 | +static void uart1_init(void); |
|
| 18 | +static void uart1_send_char(char value); |
|
| 19 | +static void uart1_send_string(const char *text); |
|
| 20 | +static void delay_ms(uint16_t milliseconds); |
|
| 21 | +static void blink_pin(GPIO_TypeDef *port, GPIO_Pin_TypeDef pin, uint8_t count); |
|
| 22 | +static void handle_command(const char *window); |
|
| 23 | + |
|
| 24 | +int main(void) |
|
| 25 | +{ |
|
| 26 | + char rx_window[3] = {'\0', '\0', '\0'}; |
|
| 27 | + |
|
| 28 | + clock_init(); |
|
| 29 | + gpio_init(); |
|
| 30 | + uart1_init(); |
|
| 31 | + |
|
| 32 | + while (1) |
|
| 33 | + { |
|
| 34 | + if (UART1_GetFlagStatus(UART1_FLAG_RXNE) != RESET) |
|
| 35 | + { |
|
| 36 | + char received = (char)UART1_ReceiveData8(); |
|
| 37 | + |
|
| 38 | + rx_window[0] = rx_window[1]; |
|
| 39 | + rx_window[1] = rx_window[2]; |
|
| 40 | + rx_window[2] = received; |
|
| 41 | + |
|
| 42 | + handle_command(rx_window); |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | +} |
|
| 46 | + |
|
| 47 | +static void clock_init(void) |
|
| 48 | +{ |
|
| 49 | + CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1); |
|
| 50 | +} |
|
| 51 | + |
|
| 52 | +static void gpio_init(void) |
|
| 53 | +{ |
|
| 54 | + GPIO_DeInit(GPIOD); |
|
| 55 | + GPIO_DeInit(GPIOB); |
|
| 56 | + |
|
| 57 | + GPIO_Init(GPIOD, GPIO_PIN_5, GPIO_MODE_OUT_PP_HIGH_FAST); |
|
| 58 | + GPIO_Init(GPIOD, GPIO_PIN_6, GPIO_MODE_IN_FL_NO_IT); |
|
| 59 | + |
|
| 60 | + GPIO_Init(GPIOB, GPIO_PIN_4, GPIO_MODE_OUT_PP_LOW_FAST); |
|
| 61 | + GPIO_Init(GPIOB, GPIO_PIN_5, GPIO_MODE_OUT_PP_LOW_FAST); |
|
| 62 | +} |
|
| 63 | + |
|
| 64 | +static void uart1_init(void) |
|
| 65 | +{ |
|
| 66 | + UART1_DeInit(); |
|
| 67 | + UART1_Init( |
|
| 68 | + UART_BAUDRATE, |
|
| 69 | + UART1_WORDLENGTH_8D, |
|
| 70 | + UART1_STOPBITS_1, |
|
| 71 | + UART1_PARITY_NO, |
|
| 72 | + UART1_SYNCMODE_CLOCK_DISABLE, |
|
| 73 | + UART1_MODE_TXRX_ENABLE); |
|
| 74 | + UART1_Cmd(ENABLE); |
|
| 75 | +} |
|
| 76 | + |
|
| 77 | +static void uart1_send_char(char value) |
|
| 78 | +{ |
|
| 79 | + while (UART1_GetFlagStatus(UART1_FLAG_TXE) == RESET) |
|
| 80 | + { |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + UART1_SendData8((uint8_t)value); |
|
| 84 | +} |
|
| 85 | + |
|
| 86 | +static void uart1_send_string(const char *text) |
|
| 87 | +{ |
|
| 88 | + while (*text != '\0') |
|
| 89 | + { |
|
| 90 | + uart1_send_char(*text); |
|
| 91 | + text++; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + while (UART1_GetFlagStatus(UART1_FLAG_TC) == RESET) |
|
| 95 | + { |
|
| 96 | + } |
|
| 97 | +} |
|
| 98 | + |
|
| 99 | +static void delay_ms(uint16_t milliseconds) |
|
| 100 | +{ |
|
| 101 | + uint16_t ms; |
|
| 102 | + volatile uint16_t ticks; |
|
| 103 | + |
|
| 104 | + for (ms = 0; ms < milliseconds; ms++) |
|
| 105 | + { |
|
| 106 | + for (ticks = 0; ticks < 1600; ticks++) |
|
| 107 | + { |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | +} |
|
| 111 | + |
|
| 112 | +static void blink_pin(GPIO_TypeDef *port, GPIO_Pin_TypeDef pin, uint8_t count) |
|
| 113 | +{ |
|
| 114 | + uint8_t index; |
|
| 115 | + |
|
| 116 | + for (index = 0; index < count; index++) |
|
| 117 | + { |
|
| 118 | + GPIO_WriteHigh(port, pin); |
|
| 119 | + delay_ms(1000); |
|
| 120 | + GPIO_WriteLow(port, pin); |
|
| 121 | + delay_ms(1000); |
|
| 122 | + } |
|
| 123 | +} |
|
| 124 | + |
|
| 125 | +static void handle_command(const char *window) |
|
| 126 | +{ |
|
| 127 | + if ((window[0] == '5') && (window[1] == '5') && (window[2] == '5')) |
|
| 128 | + { |
|
| 129 | + uart1_send_string("OK555\r\n"); |
|
| 130 | + blink_pin(GPIOB, GPIO_PIN_5, BLINK_COUNT); |
|
| 131 | + } |
|
| 132 | + else if ((window[0] == '4') && (window[1] == '4') && (window[2] == '4')) |
|
| 133 | + { |
|
| 134 | + uart1_send_string("OK444\r\n"); |
|
| 135 | + blink_pin(GPIOB, GPIO_PIN_4, BLINK_COUNT); |
|
| 136 | + } |
|
| 137 | +} |
|
| 138 | + |
Tech-dat/tech-dat.md
| ... | ... | @@ -65,7 +65,7 @@ |
| 65 | 65 | |
| 66 | 66 | - [[ESP-SDK-dat]] - [[esp32-sdk-dat]] - [[esp8266-sdk-dat]] |
| 67 | 67 | |
| 68 | -- [[STM32-SDK-dat]] |
|
| 68 | +- [[STM32-Cube-programmer-dat]] - [[STM32-SDK-dat]] - [[STM8-SDK-dat]] - [[ST-LINK-dat]] - [[SDK-dat]] |
|
| 69 | 69 | |
| 70 | 70 | - [[MDK-ARM-dat]] |
| 71 | 71 | |
| ... | ... | @@ -73,6 +73,9 @@ |
| 73 | 73 | |
| 74 | 74 | - [[encryption-dat]] |
| 75 | 75 | |
| 76 | + |
|
| 77 | + |
|
| 78 | + |
|
| 76 | 79 | ### network |
| 77 | 80 | |
| 78 | 81 | == Proprietary |