Files
stm8stest/oldtest/main.h

51 lines
1.3 KiB
C

#ifndef __MAIN_H
#define __MAIN_H
#include "stm8s.h"
#include "stm8s_it.h" /* SDCC patch: required by SDCC for interrupts */
/* automatically use built-in LED for known nucleo boards */
#if defined(STM8S_NUCLEO_208RB) || defined(STM8S_NUCLEO_207K8)
#define LED_GPIO_PORT (GPIOC)
#define LED_GPIO_PINS (GPIO_PIN_5)
#elif defined(STM8S103)
/* for STM8S103F3 breakout board. building with GPIOG would result in failure (chip
* does not have that GPIO peripheral) */
#define LED_GPIO_PORT (GPIOB)
#define LED_GPIO_PINS (GPIO_PIN_5)
#else
#define LED_GPIO_PORT (GPIOG)
#define LED_GPIO_PINS (GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1 | GPIO_PIN_0)
#endif
#ifdef _RAISONANCE_
#define PUTCHAR_PROTOTYPE int putchar (char c)
#define GETCHAR_PROTOTYPE int getchar (void)
#elif defined (_COSMIC_)
#define PUTCHAR_PROTOTYPE char putchar (char c)
#define GETCHAR_PROTOTYPE char getchar (void)
#else /* _IAR_ */
#define PUTCHAR_PROTOTYPE int putchar (int c)
#define GETCHAR_PROTOTYPE int getchar (void)
#endif /* _RAISONANCE_ */
#define US(us) ( F_CPU / 6000000.0 * us )
inline void delay_count (uint16_t nCount) {
/* Decrement nCount value */
while (nCount != 0)
{
nCount--;
}
}
inline void delay_ms(uint32_t ms) {
while (ms != 0) {
ms--;
delay_count(US(1000));
}
}
extern uint32_t ms_passed;
#endif