Inlined STM8S SPL (STM8S103) for use with SDCC

bootstrap.h 946B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // Created by MightyPork on 2017/02/10.
  3. //
  4. #ifndef STM8S_STDINIT_H
  5. #define STM8S_STDINIT_H
  6. /** Global timebase */
  7. extern volatile uint32_t time_ms;
  8. /** Uart IRQ handler */
  9. void UART1_RX_IRQHandler(void) INTERRUPT(18);
  10. /** SysTick handler */
  11. void TIM4_UPD_OVF_IRQHandler(void) INTERRUPT(23);
  12. /** putchar, used by the SDCC stdlib */
  13. void putchar(char c);
  14. /**
  15. * Simple init (UART, LED, timebase)
  16. */
  17. void SimpleInit(void);
  18. /**
  19. * Millisecond delay
  20. *
  21. * @param ms - nr of milliseconds
  22. */
  23. void Delay(uint16_t ms);
  24. /**
  25. * User UART rx handler
  26. *
  27. * If adding custom handler, comment out the defualt echo impl in bootstrap.c
  28. *
  29. * @param c
  30. */
  31. extern void UART_HandleRx(char c);
  32. /** Toggle indicator LED */
  33. inline void LED_Toggle(void)
  34. {
  35. GPIOB->ODR ^= GPIO_PIN_5;
  36. }
  37. /** Set indicator LED */
  38. inline void LED_Set(bool state)
  39. {
  40. if (state) {
  41. GPIOB->ODR &= ~GPIO_PIN_5;
  42. } else {
  43. GPIOB->ODR |= GPIO_PIN_5;
  44. }
  45. }
  46. #endif //STM8S_DEBUG_H