diff --git a/include/delay.h b/include/delay.h new file mode 100644 index 0000000..9bc1614 --- /dev/null +++ b/include/delay.h @@ -0,0 +1,13 @@ +#ifndef __DELAY_H__ +#define __DELAY_H__ + +#include + +extern volatile uint32_t tick; + +/** + * @brief wait for specific time in ms. May not be caleed from interrupt context + */ +void delay_ms(uint32_t ms); + +#endif /* __DELAY_H__ */ diff --git a/include/lcd.h b/include/lcd.h new file mode 100644 index 0000000..2935ae3 --- /dev/null +++ b/include/lcd.h @@ -0,0 +1,43 @@ +#ifndef __LCD_H__ +#define __LCD_H__ + +#include + +#define LCD_DPORT (GPIOA) +#define LCD_DATA_BIT_OFFSET (0) +#define LCD_RS (9) +#define LCD_E (10) + +#define LCD_DATA_MASK (0xFU << LCD_DATA_BIT_OFFSET) +#define LCD_RS_MASK (1U << LCD_RS) +#define LCD_E_MASK (1U << LCD_E) + +/** + * @brief Initialize 4 bit LCD mode. GPIOs have to be set up prior to any call of this function + */ +void lcd_init(void); + +/** + * @brief Clear display + */ +void lcd_clear(void); + +/** + * @brief Set cursor position to 0/0 + */ +void lcd_home(void); + +/** + * @brief Set cursor to position \p x \p y + * @param x Position in line + * @param y Line + */ +void lcd_setcursor(uint8_t x, uint8_t y); + +/** + * @brief Write string to current cursor position + * @param String to write + */ +void lcd_string(const char *data); + +#endif /* __LCD_H__ */ diff --git a/include/stm32f030x6.h b/include/stm32f030x6.h index c06fe71..b1c6ae9 100644 --- a/include/stm32f030x6.h +++ b/include/stm32f030x6.h @@ -365,8 +365,15 @@ typedef struct { __IO uint32_t CR1; /*!< SPI Control register 1 (not used in I2S mode), Address offset: 0x00 */ __IO uint32_t CR2; /*!< SPI Control register 2, Address offset: 0x04 */ - __IO uint32_t SR; /*!< SPI Status register, Address offset: 0x08 */ - __IO uint32_t DR; /*!< SPI data register, Address offset: 0x0C */ + __IO uint32_t SR; /*!< SPI Status register, Address offset: 0x08 */ + union DR_ { + __IO uint16_t DR16; /*!< SPI data register, Address offset: 0x0C */ + struct DR8_ { + __IO uint8_t DR8_1; + __IO uint8_t DR8_2; + } DR8; + } DR; + __IO uint16_t DR_DUMMY; __IO uint32_t CRCPR; /*!< SPI CRC polynomial register (not used in I2S mode), Address offset: 0x10 */ __IO uint32_t RXCRCR; /*!< SPI Rx CRC register (not used in I2S mode), Address offset: 0x14 */ __IO uint32_t TXCRCR; /*!< SPI Tx CRC register (not used in I2S mode), Address offset: 0x18 */