stm8s/main.h

47 lines
1.3 KiB
C

// get length of array
#define ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0]))
// LED to indicate valid EDID
// sink to witch on
// off = firmware not running
// on = valid EDID
// blink = no valid EDID
#define EDID_LED_PORT GPIO_PD
#define EDID_LED_PIN PD4
#define edid_led_on() {EDID_LED_PORT->ODR.reg &= ~EDID_LED_PIN;}
#define edid_led_off() {EDID_LED_PORT->ODR.reg |= EDID_LED_PIN;}
#define edid_led_toggle() {EDID_LED_PORT->ODR.reg ^= EDID_LED_PIN;}
// LED to indicate operation read/write result
// sink to switch on
// off = no operation started
// on = operation succeeded
// blink = operation failed
#define RUN_LED_PORT GPIO_PD
#define RUN_LED_PIN PD6
#define run_led_on() {RUN_LED_PORT->ODR.reg &= ~RUN_LED_PIN;}
#define run_led_off() {RUN_LED_PORT->ODR.reg |= RUN_LED_PIN;}
#define run_led_toggle() {RUN_LED_PORT->ODR.reg ^= RUN_LED_PIN;
// button to start read/write operation
// press shorts it to ground
// short press = read EDID
// long press (> 3s) = write EDID
#define RW_BUTTON_PORT GPIO_PD
#define RW_BUTTON_PIN PD3
// start address of EEPROM
#define EEPROM_ADDR 0x4000
// address of I²C EEPROM slave device containing EDID information
#define I2C_SLAVE 0x50
/** print character
* @param[in] c character to print
*/
void putc(char c);
/** print string
* @param[in] s string to print
*/
void puts(const char* s);