STM32H750VB_LCD/Core/Src/otm_lcd_impl.c

52 lines
1.2 KiB
C

#include "stm32h7xx_hal.h"
#include "main.h"
#include "otm_lcd_impl.h"
#define LCD_REGISTER_ADDR 0x60000000
#define LCD_DATA_ADDR 0x60020000
static void _otm_dma_transfer_complete(DMA_HandleTypeDef *DmaHandle) {
//osSemaphoreRelease(DmaHandle->);
}
static void _otm_dma_transfer_error(DMA_HandleTypeDef *DmaHandle) {
// osSemaphoreGive
}
void _otm_impl_init(void *handle) {
_otm_impl_t *impl = handle;
impl->dma_semphr = osSemaphoreNew(1, 0, NULL);
}
otm_ret_t _otm_impl_write_reg(void *handle, otm_data_t *reg, uint8_t len) {
*(uint16_t *)LCD_REGISTER_ADDR = *reg;
for(uint8_t i = 1; i < len; i++) {
*(uint16_t *)LCD_DATA_ADDR = reg[i];
}
return OTM_OK;
}
otm_ret_t _otm_impl_write_data(void *handle, otm_data_t *data, uint32_t len) {
for(uint32_t i = 0; i < len; i++){
*(uint16_t *)LCD_DATA_ADDR = data[i];
}
//HAL_DMA_RegisterCallback()
return OTM_OK;
}
otm_ret_t _otm_impl_delay(void *handle, uint32_t usec) {
HAL_Delay(usec / 1000);
return OTM_OK;
}
otm_ret_t _otm_impl_backlight(void *handle, uint8_t on) {
HAL_GPIO_WritePin(LCD_BL_GPIO_Port, LCD_BL_Pin, on ? GPIO_PIN_SET : GPIO_PIN_RESET);
return OTM_OK;
}