Clean project structure up, added some commented out functions to try make the ST7789 round lcd work (was a failure). Added the i2c.h and .c file, still work to be done on that side. The round LCD display is using a 3-line 9 bit serial interface ... This suck !
This commit is contained in:
parent
eeaf819b80
commit
65a1a5dd49
@ -3,8 +3,9 @@ sinclude $(TOP_DIR)/tools/w800/conf.mk
|
||||
|
||||
ifndef PDIR
|
||||
GEN_LIBS = libdrivers$(LIB_EXT)
|
||||
COMPONENTS_libdrivers = lcd/libdriverslcd$(LIB_EXT)
|
||||
COMPONENTS_libdrivers = mmc_sdio/libdriversmmc_sdio$(LIB_EXT)
|
||||
COMPONENTS_libdrivers = lcd/libdriverslcd$(LIB_EXT) \
|
||||
mmc_sdio/libdriversmmc_sdio$(LIB_EXT) \
|
||||
i2c/libdriversi2c$(LIB_EXT)
|
||||
endif
|
||||
|
||||
#DEFINES +=
|
15
src/W800 SDK v1.00.08/app/drivers/i2c/Makefile
Normal file
15
src/W800 SDK v1.00.08/app/drivers/i2c/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
TOP_DIR = ../../..
|
||||
sinclude $(TOP_DIR)/tools/w800/conf.mk
|
||||
|
||||
ifndef PDIR
|
||||
GEN_LIBS = libdriversi2c$(LIB_EXT)
|
||||
endif
|
||||
|
||||
#DEFINES +=
|
||||
|
||||
sinclude $(TOP_DIR)/tools/w800/rules.mk
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
11
src/W800 SDK v1.00.08/app/drivers/i2c/i2c.c
Normal file
11
src/W800 SDK v1.00.08/app/drivers/i2c/i2c.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include "wm_type_def.h"
|
||||
#include "wm_io.h"
|
||||
#include "wm_gpio_afsel.h"
|
||||
#include "wm_i2c.h"
|
||||
|
||||
void i2c_init(enum tls_io_name SDAPin, enum tls_io_name SCLPin, uint32_t frequency)
|
||||
{
|
||||
wm_i2c_sda_config(SDAPin);
|
||||
wm_i2c_scl_config(SCLPin);
|
||||
tls_i2c_init(frequency);
|
||||
}
|
12
src/W800 SDK v1.00.08/app/drivers/i2c/i2c.h
Normal file
12
src/W800 SDK v1.00.08/app/drivers/i2c/i2c.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef I2C_H
|
||||
#define I2C_H
|
||||
|
||||
#include "wm_type_def.h"
|
||||
#include "wm_io.h"
|
||||
|
||||
void i2c_init(enum tls_io_name SDAPin, enum tls_io_name SCLPin, uint32_t frequency);
|
||||
|
||||
bool i2c_write(uint8_t address, const uint8_t *data, size_t length, bool sendStop);
|
||||
|
||||
|
||||
#endif //I2C_H
|
@ -3,7 +3,6 @@ sinclude $(TOP_DIR)/tools/w800/conf.mk
|
||||
|
||||
ifndef PDIR
|
||||
GEN_LIBS = libdriverslcd$(LIB_EXT)
|
||||
COMPONENTS_libdriverslcd = ../mmc_sdio/libdriversmmc_sdio$(LIB_EXT)
|
||||
endif
|
||||
|
||||
#DEFINES +=
|
@ -1,31 +1,35 @@
|
||||
#include <string.h>
|
||||
#include "FreeRTOS.h"
|
||||
#include "mmc_sdio.h"
|
||||
#include "lcd.h"
|
||||
#include "app_log.h"
|
||||
|
||||
static void lcd_write_cmd_data_bytes(LCDConfig_t * const LCDConfig, const u8 *cmdAndData, u32 dataLengthInBytes)
|
||||
{
|
||||
// Select the slave CS line and tell him that he will receive a command !
|
||||
lcd_set_cs(LCDConfig, LCD_SELECTED);
|
||||
lcd_set_data_command(LCDConfig, LCD_COMMAND);
|
||||
/**
|
||||
* @brief Prototype of functions only used internally :
|
||||
*
|
||||
*/
|
||||
|
||||
mmc_sdio_driver_write_one(*cmdAndData++);
|
||||
if(dataLengthInBytes >= 2)
|
||||
{
|
||||
lcd_set_data_command(LCDConfig, LCD_DATA);
|
||||
/* Sets the LCD write window area */
|
||||
static void lcd_set_window(LCDConfig_t * const LCDConfig, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end);
|
||||
|
||||
for (size_t i = 0; i < dataLengthInBytes - 1; ++i)
|
||||
mmc_sdio_driver_write_one(*cmdAndData++);
|
||||
}
|
||||
/* Sets the chip select pin */
|
||||
static void lcd_set_cs(LCDConfig_t * const LCDConfig, LCDSelect_e selected);
|
||||
|
||||
// We release the slave CS line and tell him that we are in DATA mode
|
||||
lcd_set_cs(LCDConfig, LCD_RELEASED);
|
||||
lcd_set_data_command(LCDConfig, LCD_DATA);
|
||||
}
|
||||
/* Sets the data/command pin state */
|
||||
static void lcd_set_data_command(LCDConfig_t * const LCDConfig, LCDDataCommand_e dataCommand);
|
||||
|
||||
/**
|
||||
* @brief Writes a command byte + dataLengthInBytes - 1 data bytes.
|
||||
*
|
||||
* @param LCDConfig a pointer a user allocated LCDConfig_t structure
|
||||
* @param cmdAndData a buffer containing one command byte + X data bytes
|
||||
* @param dataLengthInBytes the length of the buffer ie : 1 + X data bytes
|
||||
*/
|
||||
static void lcd_write_cmd_data_bytes(LCDConfig_t * const LCDConfig, const uint8_t *cmdAndData, uint32_t dataLengthInBytes);
|
||||
|
||||
// ST7789初始化
|
||||
const uint8_t st7789_init_seq[] = {
|
||||
/* len , delay, cmd, data ... */
|
||||
/*const uint8_t st7789_init_seq[] = {
|
||||
// len , delay, cmd, data ...
|
||||
0x01, 0x14, 0x01, // Software reset
|
||||
0x01, 0x0A, 0x11, // Exit sleep mode
|
||||
0x02, 0x02, 0x3A, 0x55, // Set colour mode to 16 bit
|
||||
@ -36,6 +40,34 @@ const uint8_t st7789_init_seq[] = {
|
||||
0x01, 0x02, 0x13, // Normal display on, then 10 ms delay
|
||||
0x01, 0x02, 0x29, // Main screen turn on, then wait 500 ms
|
||||
0 // Terminate list
|
||||
};*/
|
||||
|
||||
const uint8_t st7789_init_seq[] = {
|
||||
/* len , delay, cmd, data ... */
|
||||
0x01, // Software reset
|
||||
0x11, // Exit sleep mode
|
||||
//0x02, 0x02, 0x3A, 0x05, // Set colour mode to 16 bit
|
||||
//0x02, 0x0A, 0x36, 0x00, // Set MADCTL: row then column, refresh is bottom to top ????
|
||||
//0x05, 0x0A, 0x2A, 0x00, 0x00, 0x00, 0xf0, // CASET: column addresses from 0 to 240 (f0)
|
||||
//0x05, 0x0A, 0x2B, 0x00, 0x00, 0x01, 0x40, // RASET: row addresses from 0 to 240 (f0)
|
||||
//0x01, 0x0A, 0x21, // Inversion on, then 10 ms delay (supposedly a hack?)
|
||||
0x13, // Normal display on, then 10 ms delay
|
||||
0x29, // Main screen turn on, then wait 500 ms
|
||||
0 // Terminate list
|
||||
};
|
||||
|
||||
const uint8_t st7789_init_seq_9_bit[] = {
|
||||
/* len , delay, cmd, data ... */
|
||||
0x01, 0x14, 0x01, // Software reset
|
||||
0x01, 0x0A, 0x11, // Exit sleep mode
|
||||
//0x02, 0x02, 0x3A, 0x05, // Set colour mode to 16 bit
|
||||
//0x02, 0x0A, 0x36, 0x00, // Set MADCTL: row then column, refresh is bottom to top ????
|
||||
//0x05, 0x0A, 0x2A, 0x00, 0x00, 0x00, 0xf0, // CASET: column addresses from 0 to 240 (f0)
|
||||
//0x05, 0x0A, 0x2B, 0x00, 0x00, 0x01, 0x40, // RASET: row addresses from 0 to 240 (f0)
|
||||
//0x01, 0x0A, 0x21, // Inversion on, then 10 ms delay (supposedly a hack?)
|
||||
0x01, 0x0A, 0x13, // Normal display on, then 10 ms delay
|
||||
0x01, 0x0A, 0x29, // Main screen turn on, then wait 500 ms
|
||||
0 // Terminate list
|
||||
};
|
||||
|
||||
/**
|
||||
@ -139,6 +171,8 @@ void lcd_config_init(LCDConfig_t * const LCDConfig)
|
||||
{
|
||||
if(!LCDConfig) return;
|
||||
|
||||
memset(LCDConfig, 0, sizeof(LCDConfig_t));
|
||||
|
||||
LCDConfig->LCDPWMBacklightPin = -1;
|
||||
LCDConfig->LCDClockPin = -1;
|
||||
LCDConfig->LCDDataPin = -1;
|
||||
@ -148,6 +182,76 @@ void lcd_config_init(LCDConfig_t * const LCDConfig)
|
||||
|
||||
}
|
||||
|
||||
/*void spi_write_9_bit(LCDConfig_t * const LCDConfig, bool data, uint8_t op)
|
||||
{
|
||||
lcd_set_cs(LCDConfig, LCD_SELECTED);
|
||||
|
||||
if(data)
|
||||
{
|
||||
tls_gpio_write(LCDConfig->LCDDataPin, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
tls_gpio_write(LCDConfig->LCDDataPin, 0);
|
||||
}
|
||||
|
||||
tls_gpio_write(LCDConfig->LCDClockPin, 1);
|
||||
|
||||
tls_gpio_write(LCDConfig->LCDClockPin, 0);
|
||||
|
||||
|
||||
for(uint8_t i = 0; i < 8; i++)
|
||||
{
|
||||
tls_gpio_write(LCDConfig->LCDDataPin, op & 0x80);
|
||||
|
||||
tls_gpio_write(LCDConfig->LCDClockPin, 1);
|
||||
|
||||
tls_gpio_write(LCDConfig->LCDClockPin, 0);
|
||||
|
||||
|
||||
op <<= 1;
|
||||
}
|
||||
|
||||
lcd_set_cs(LCDConfig, LCD_RELEASED);
|
||||
}*/
|
||||
|
||||
/*void spi_write_9_bit(LCDConfig_t * const LCDConfig, bool data, uint8_t op)
|
||||
{
|
||||
if(data)
|
||||
{
|
||||
lcd_set_data_command(LCDConfig, LCD_DATA);
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd_set_data_command(LCDConfig, LCD_COMMAND);
|
||||
}
|
||||
APP_LOG_DEBUG("A");//for(volatile uint32_t i = 0; i < 1000; i++);
|
||||
lcd_set_cs(LCDConfig, LCD_SELECTED);
|
||||
|
||||
for(uint8_t i = 0; i < 8; i++)
|
||||
{
|
||||
tls_gpio_write(LCDConfig->LCDDataPin, op & 0x80);
|
||||
APP_LOG_DEBUG("B");//for(volatile uint32_t i = 0; i < 1000; i++);
|
||||
tls_gpio_write(LCDConfig->LCDClockPin, 0);
|
||||
APP_LOG_DEBUG("C");//for(volatile uint32_t i = 0; i < 1000; i++);
|
||||
tls_gpio_write(LCDConfig->LCDClockPin, 1);
|
||||
APP_LOG_DEBUG("D");//for(volatile uint32_t i = 0; i < 1000; i++);
|
||||
|
||||
op <<= 1;
|
||||
}
|
||||
|
||||
APP_LOG_DEBUG("E");//for(volatile uint32_t i = 0; i < 1000; i++);
|
||||
lcd_set_cs(LCDConfig, LCD_RELEASED);
|
||||
}*/
|
||||
|
||||
void lcd_register_draw_finished_cb(LCDConfig_t * const LCDConfig, DrawFinishedCb_t drawFinishedCb, void *arg)
|
||||
{
|
||||
if(!LCDConfig) return;
|
||||
|
||||
LCDConfig->drawFinishedCb = drawFinishedCb;
|
||||
LCDConfig->cbArg = arg;
|
||||
}
|
||||
|
||||
void lcd_init(LCDConfig_t * const LCDConfig)
|
||||
{
|
||||
if(!LCDConfig) return;
|
||||
@ -159,9 +263,16 @@ void lcd_init(LCDConfig_t * const LCDConfig)
|
||||
tls_gpio_cfg(LCDConfig->LCDDataCommandPin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
|
||||
tls_gpio_cfg(LCDConfig->LCDResetPin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_PULLHIGH);
|
||||
|
||||
#if 1
|
||||
// The clock and data line are driven using the MMC peripheral
|
||||
tls_io_cfg_set(LCDConfig->LCDClockPin, WM_IO_OPTION2);
|
||||
tls_io_cfg_set(LCDConfig->LCDDataPin, WM_IO_OPTION2);
|
||||
#else
|
||||
tls_gpio_cfg(LCDConfig->LCDClockPin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
|
||||
tls_gpio_write(LCDConfig->LCDClockPin, 1);
|
||||
tls_gpio_cfg(LCDConfig->LCDDataPin, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_FLOATING);
|
||||
tls_gpio_write(LCDConfig->LCDDataPin, 1);
|
||||
#endif
|
||||
|
||||
// We set some of the pins default value
|
||||
lcd_set_backlight(LCDConfig, 0);
|
||||
@ -171,8 +282,9 @@ void lcd_init(LCDConfig_t * const LCDConfig)
|
||||
lcd_hardware_reset(LCDConfig);
|
||||
|
||||
// Init MMC SDIO peripheral
|
||||
mmc_sdio_driver_periph_init();
|
||||
mmc_sdio_driver_periph_init(LCDConfig->drawFinishedCb, LCDConfig->cbArg);
|
||||
|
||||
#if 1
|
||||
#if DISPLAY_CONTROLLER == 0
|
||||
const u8 *cmd = ili9341_init_seq;
|
||||
#elif DISPLAY_CONTROLLER == 1
|
||||
@ -187,46 +299,66 @@ void lcd_init(LCDConfig_t * const LCDConfig)
|
||||
tls_os_time_delay(*(cmd + 1));
|
||||
cmd += *cmd + 2;
|
||||
}
|
||||
#else
|
||||
lcd_set_data_command(LCDConfig, LCD_COMMAND);
|
||||
lcd_set_cs(LCDConfig, LCD_SELECTED);
|
||||
|
||||
mmc_sdio_driver_write_one(0x00);
|
||||
mmc_sdio_driver_write_one(0x80);
|
||||
|
||||
lcd_set_cs(LCDConfig, LCD_RELEASED);
|
||||
tls_os_time_delay(4);
|
||||
lcd_set_cs(LCDConfig, LCD_SELECTED);
|
||||
|
||||
mmc_sdio_driver_write_one(0x08);
|
||||
mmc_sdio_driver_write_one(0x80);
|
||||
|
||||
lcd_set_cs(LCDConfig, LCD_RELEASED);
|
||||
tls_os_time_delay(4);
|
||||
lcd_set_cs(LCDConfig, LCD_SELECTED);
|
||||
|
||||
mmc_sdio_driver_write_one(0x09);
|
||||
mmc_sdio_driver_write_one(0x80);
|
||||
|
||||
lcd_set_cs(LCDConfig, LCD_RELEASED);
|
||||
tls_os_time_delay(4);
|
||||
lcd_set_cs(LCDConfig, LCD_SELECTED);
|
||||
|
||||
mmc_sdio_driver_write_one(0x14);
|
||||
mmc_sdio_driver_write_one(0x80);
|
||||
tls_os_time_delay(4);
|
||||
|
||||
lcd_set_cs(LCDConfig, LCD_RELEASED);
|
||||
|
||||
/*
|
||||
spi_write_9_bit(LCDConfig, false, 0x01);
|
||||
tls_os_time_delay(2);
|
||||
spi_write_9_bit(LCDConfig, false, 0x11);
|
||||
tls_os_time_delay(2);
|
||||
spi_write_9_bit(LCDConfig, false, 0x3A);spi_write_9_bit(LCDConfig, true, 0x05);
|
||||
tls_os_time_delay(2);
|
||||
spi_write_9_bit(LCDConfig, false, 0x36);spi_write_9_bit(LCDConfig, true, 0x00);
|
||||
tls_os_time_delay(2);
|
||||
|
||||
|
||||
spi_write_9_bit(LCDConfig, false, 0x2A);spi_write_9_bit(LCDConfig, true, 0x00);spi_write_9_bit(LCDConfig, true, 0x00);spi_write_9_bit(LCDConfig, true, 0x00);spi_write_9_bit(LCDConfig, true, 0xF0);
|
||||
tls_os_time_delay(2);
|
||||
spi_write_9_bit(LCDConfig, false, 0x2B);spi_write_9_bit(LCDConfig, true, 0x00);spi_write_9_bit(LCDConfig, true, 0x00);spi_write_9_bit(LCDConfig, true, 0x01);spi_write_9_bit(LCDConfig, true, 0x40);
|
||||
tls_os_time_delay(2);
|
||||
|
||||
spi_write_9_bit(LCDConfig, false, 0x21);tls_os_time_delay(2);
|
||||
spi_write_9_bit(LCDConfig, false, 0x13);tls_os_time_delay(2);
|
||||
spi_write_9_bit(LCDConfig, false, 0x29);
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
lcd_set_backlight(LCDConfig, 1);
|
||||
}
|
||||
|
||||
static void lcd_ram_write_mode(LCDConfig_t * const LCDConfig)
|
||||
void lcd_draw_rect_frame(LCDConfig_t * const LCDConfig, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t *data)
|
||||
{
|
||||
u8 cmd = 0x2C; // RAMWR
|
||||
lcd_write_cmd_data_bytes(LCDConfig, &cmd, 1);
|
||||
}
|
||||
|
||||
void lcd_set_window(LCDConfig_t * const LCDConfig, u16 x_start, u16 y_start, u16 x_end, u16 y_end)
|
||||
{
|
||||
u8 dataCommand[] =
|
||||
{
|
||||
0x2A, x_start>>8, 0x00FF&x_start, x_end>>8, 0x00FF&x_end,
|
||||
0x2B, y_start>>8, 0x00FF&y_start, y_end>>8, 0x00FF&y_end
|
||||
};
|
||||
|
||||
lcd_write_cmd_data_bytes(LCDConfig, dataCommand, 5);
|
||||
lcd_write_cmd_data_bytes(LCDConfig, dataCommand + 5, 5);
|
||||
|
||||
/*lcd_write_cmd_byte(0x2A);
|
||||
lcd_write_data_byte(x_start>>8);
|
||||
lcd_write_data_byte(0x00FF&x_start);
|
||||
lcd_write_data_byte(x_end>>8);
|
||||
lcd_write_data_byte(0x00FF&x_end);
|
||||
|
||||
lcd_write_cmd_byte(0x2B);
|
||||
lcd_write_data_byte(y_start>>8);
|
||||
lcd_write_data_byte(0x00FF&y_start);
|
||||
lcd_write_data_byte(y_end>>8);
|
||||
lcd_write_data_byte(0x00FF&y_end);*/
|
||||
|
||||
lcd_ram_write_mode(LCDConfig);
|
||||
}
|
||||
|
||||
void lcd_draw_rect_frame(LCDConfig_t * const LCDConfig, u16 x, u16 y, u16 width, u16 height, u8 *data)
|
||||
{
|
||||
// First we check if the MMC peripheral is ready to write :
|
||||
//mmc_sdio_driver_wait_write_dma_ready();
|
||||
if(!LCDConfig) return;
|
||||
|
||||
// We tell the display where we want to draw the frame as well as it's size
|
||||
lcd_set_window(LCDConfig, x, y, x + width - 1, y + height - 1);
|
||||
@ -236,49 +368,78 @@ void lcd_draw_rect_frame(LCDConfig_t * const LCDConfig, u16 x, u16 y, u16 width,
|
||||
|
||||
// We flush the data to the display
|
||||
mmc_sdio_driver_write_dma_async((u32*) data, width * height * 2);
|
||||
|
||||
/*for(uint32_t i = 0; i < width * height * 2; i++)
|
||||
{
|
||||
mmc_sdio_driver_write_one(data[i]);
|
||||
}*/
|
||||
|
||||
/*uint16_t size = width * height * 2, cursor = 0;
|
||||
u16 writeLen = 0;
|
||||
for(; size != 0; )
|
||||
{
|
||||
if(size > 512)
|
||||
writeLen = 512;
|
||||
else
|
||||
writeLen = size;
|
||||
|
||||
mmc_sdio_driver_write(data + cursor, writeLen);
|
||||
size -= writeLen;
|
||||
cursor += writeLen;
|
||||
}*/
|
||||
}
|
||||
|
||||
void lcd_set_backlight(LCDConfig_t * const LCDConfig, u8 brightness)
|
||||
void lcd_set_backlight(LCDConfig_t * const LCDConfig, uint8_t brightness)
|
||||
{
|
||||
if(!LCDConfig) return;
|
||||
|
||||
if(brightness)
|
||||
tls_gpio_write(LCDConfig->LCDPWMBacklightPin, 1);
|
||||
else
|
||||
tls_gpio_write(LCDConfig->LCDPWMBacklightPin, 1);
|
||||
}
|
||||
|
||||
void lcd_set_cs(LCDConfig_t * const LCDConfig, LCDSelect_e selected)
|
||||
{
|
||||
// CS is active low...
|
||||
tls_gpio_write(LCDConfig->LCDChipSelectPin, selected);
|
||||
}
|
||||
|
||||
void lcd_set_data_command(LCDConfig_t * const LCDConfig, LCDDataCommand_e dataCommand)
|
||||
{
|
||||
tls_gpio_write(LCDConfig->LCDDataCommandPin, dataCommand);
|
||||
tls_gpio_write(LCDConfig->LCDPWMBacklightPin, 0);
|
||||
}
|
||||
|
||||
void lcd_hardware_reset(LCDConfig_t * const LCDConfig)
|
||||
{
|
||||
tls_gpio_write(LCDConfig->LCDResetPin, 0);
|
||||
tls_os_time_delay(/*pdMS_TO_TICKS(1)*/100);
|
||||
tls_os_time_delay(1);
|
||||
tls_gpio_write(LCDConfig->LCDResetPin, 1);
|
||||
}
|
||||
|
||||
static void lcd_write_cmd_data_bytes(LCDConfig_t * const LCDConfig, const uint8_t *cmdAndData, uint32_t dataLengthInBytes)
|
||||
{
|
||||
// Select the slave CS line and tell him that he will receive a command !
|
||||
lcd_set_data_command(LCDConfig, LCD_COMMAND);
|
||||
lcd_set_cs(LCDConfig, LCD_SELECTED);
|
||||
mmc_sdio_driver_write_one(*cmdAndData++);
|
||||
if(dataLengthInBytes >= 2)
|
||||
{
|
||||
lcd_set_data_command(LCDConfig, LCD_DATA);
|
||||
|
||||
for (size_t i = 0; i < dataLengthInBytes - 1; ++i)
|
||||
{
|
||||
mmc_sdio_driver_write_one(*cmdAndData++);
|
||||
}
|
||||
}
|
||||
|
||||
// We release the slave CS line and tell him that we are in DATA mode
|
||||
lcd_set_cs(LCDConfig, LCD_RELEASED);
|
||||
lcd_set_data_command(LCDConfig, LCD_DATA);
|
||||
}
|
||||
|
||||
static void lcd_ram_write_mode(LCDConfig_t * const LCDConfig)
|
||||
{
|
||||
lcd_set_data_command(LCDConfig, LCD_COMMAND);
|
||||
lcd_set_cs(LCDConfig, LCD_SELECTED);
|
||||
|
||||
mmc_sdio_driver_write_one(0x2C);
|
||||
|
||||
lcd_set_cs(LCDConfig, LCD_RELEASED);
|
||||
lcd_set_data_command(LCDConfig, LCD_DATA);
|
||||
}
|
||||
|
||||
static void lcd_set_window(LCDConfig_t * const LCDConfig, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end)
|
||||
{
|
||||
uint8_t dataCommand[] =
|
||||
{
|
||||
0x2A, x_start>>8, 0x00FF&x_start, x_end>>8, 0x00FF&x_end,
|
||||
0x2B, y_start>>8, 0x00FF&y_start, y_end>>8, 0x00FF&y_end
|
||||
};
|
||||
|
||||
lcd_write_cmd_data_bytes(LCDConfig, dataCommand, 5);
|
||||
lcd_write_cmd_data_bytes(LCDConfig, dataCommand + 5, 5);
|
||||
|
||||
lcd_ram_write_mode(LCDConfig);
|
||||
}
|
||||
|
||||
static void lcd_set_cs(LCDConfig_t * const LCDConfig, LCDSelect_e selected)
|
||||
{
|
||||
// CS is active low...
|
||||
tls_gpio_write(LCDConfig->LCDChipSelectPin, selected);
|
||||
}
|
||||
|
||||
static void lcd_set_data_command(LCDConfig_t * const LCDConfig, LCDDataCommand_e dataCommand)
|
||||
{
|
||||
tls_gpio_write(LCDConfig->LCDDataCommandPin, dataCommand);
|
||||
}
|
106
src/W800 SDK v1.00.08/app/drivers/lcd/lcd.h
Normal file
106
src/W800 SDK v1.00.08/app/drivers/lcd/lcd.h
Normal file
@ -0,0 +1,106 @@
|
||||
#ifndef LCD_H
|
||||
#define LCD_H
|
||||
|
||||
#include "wm_include.h"
|
||||
|
||||
/* Used SOC : W800 or W801 */
|
||||
#define W800
|
||||
|
||||
/* Display drive controller */
|
||||
#define ILI9341 0
|
||||
#define ST7789V 1
|
||||
#define DISPLAY_CONTROLLER ILI9341
|
||||
//#define DISPLAY_CONTROLLER ST7789V
|
||||
|
||||
/* Display properties */
|
||||
#define LCD_PIXEL_WIDTH 240
|
||||
#define LCD_PIXEL_HEIGHT 240
|
||||
|
||||
typedef enum LCDDataCommand
|
||||
{
|
||||
LCD_COMMAND = 0,
|
||||
LCD_DATA = 1
|
||||
} LCDDataCommand_e;
|
||||
|
||||
typedef enum LCDSelect
|
||||
{
|
||||
LCD_SELECTED = 0,
|
||||
LCD_RELEASED = 1
|
||||
} LCDSelect_e;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef void (*DrawFinishedCb_t)(void *arg);
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
typedef struct LCDConfig
|
||||
{
|
||||
enum tls_io_name LCDPWMBacklightPin;
|
||||
enum tls_io_name LCDClockPin;
|
||||
enum tls_io_name LCDDataPin;
|
||||
enum tls_io_name LCDChipSelectPin;
|
||||
enum tls_io_name LCDDataCommandPin;
|
||||
enum tls_io_name LCDResetPin;
|
||||
DrawFinishedCb_t drawFinishedCb;
|
||||
void *cbArg;
|
||||
} LCDConfig_t;
|
||||
|
||||
/**
|
||||
* @brief Initializes the LCDConfig object to known values
|
||||
* Must be called before using any other LCD Driver API functions
|
||||
*
|
||||
* @param LCDConfig a pointer a user allocated LCDConfig_t structure
|
||||
*/
|
||||
void lcd_config_init(LCDConfig_t * const LCDConfig);
|
||||
|
||||
/**
|
||||
* @brief Registers a function called by the driver once it is finished drawing on the screen and is ready for the next drawing.
|
||||
* Usually called once the DMA engine is done with the transfer.
|
||||
* /!\ MUST BE CALLED BEFORE lcd_init FUNCTION
|
||||
*
|
||||
* @param LCDConfig a pointer a user allocated LCDConfig_t structure
|
||||
* @param drawFinishedCb the function to register of the form : void myFunc(void *arg)
|
||||
* @param arg a pointer to an optional argument passed to the callback function
|
||||
*/
|
||||
void lcd_register_draw_finished_cb(LCDConfig_t * const LCDConfig, DrawFinishedCb_t drawFinishedCb, void *arg);
|
||||
|
||||
/**
|
||||
* @brief Initializes IOs using the configured LCDConfig object and the LCD display
|
||||
*
|
||||
* @param LCDConfig a pointer a user allocated LCDConfig_t structure
|
||||
*/
|
||||
void lcd_init(LCDConfig_t * const LCDConfig);
|
||||
|
||||
/**
|
||||
* @brief Writes the frame to display's internal RAM
|
||||
*
|
||||
* @param LCDConfig a pointer a user allocated LCDConfig_t structure
|
||||
* @param x
|
||||
* @param y
|
||||
* @param width
|
||||
* @param height
|
||||
* @param data
|
||||
*/
|
||||
void lcd_draw_rect_frame(LCDConfig_t * const LCDConfig, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t *data);
|
||||
|
||||
/**
|
||||
* @brief Sets the backlight to the specified brightness value
|
||||
*
|
||||
* @param LCDConfig a pointer a user allocated LCDConfig_t structure
|
||||
* @param brightness a value from 0 (backlight off) to 255 backlight fully on.
|
||||
*/
|
||||
void lcd_set_backlight(LCDConfig_t * const LCDConfig, uint8_t brightness);
|
||||
|
||||
/**
|
||||
* @brief Issues a hardware reset of the lcd display
|
||||
*
|
||||
* @param LCDConfig a pointer a user allocated LCDConfig_t structure
|
||||
*/
|
||||
void lcd_hardware_reset(LCDConfig_t * const LCDConfig);
|
||||
|
||||
#endif //LCD_H
|
119
src/W800 SDK v1.00.08/app/drivers/mmc_sdio/mmc_sdio.c
Normal file
119
src/W800 SDK v1.00.08/app/drivers/mmc_sdio/mmc_sdio.c
Normal file
@ -0,0 +1,119 @@
|
||||
#include <string.h>
|
||||
#include "wm_sdio_host.h"
|
||||
#include "wm_include.h"
|
||||
#include "app_log.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "lvgl.h"
|
||||
#include "mmc_sdio.h"
|
||||
|
||||
static uint8_t sdio_spi_dma_channel = 0xFF;
|
||||
static DMATransferDoneCb_t DMATransferDoneFuncCb = NULL;
|
||||
static void *DMATransferDoneArg = NULL;
|
||||
|
||||
|
||||
void mmc_sdio_driver_periph_init(DMATransferDoneCb_t DMATransferDoneCb, void *arg)
|
||||
{
|
||||
tls_open_peripheral_clock(TLS_PERIPHERAL_TYPE_SDIO_MASTER);
|
||||
// W800 register manual page 67
|
||||
tls_bitband_write(HR_CLK_RST_CTL, 27, 0);
|
||||
tls_bitband_write(HR_CLK_RST_CTL, 27, 1);
|
||||
// Wait until reset is released
|
||||
while (tls_bitband_read(HR_CLK_RST_CTL, 27) == 0);
|
||||
|
||||
tls_sys_clk sysclk;
|
||||
tls_sys_clk_get(&sysclk);
|
||||
|
||||
// W800 register manual page 179
|
||||
SDIO_HOST->MMC_CARDSEL = 0xC0 | (sysclk.cpuclk / 2 - 1); // enable module, enable mmcclk
|
||||
APP_LOG_DEBUG("cpu clock : %u, mmc_cardsel reg val,addr : %02X, %p ", sysclk.cpuclk, SDIO_HOST->MMC_CARDSEL, &SDIO_HOST->MMC_CARDSEL);
|
||||
|
||||
#if (1)
|
||||
/* Clock frequency is 1/2 of system clock */
|
||||
// auto transfer, mmc mode.
|
||||
SDIO_HOST->MMC_CTL = 0x542 | (0 << 3);
|
||||
#else
|
||||
/* Clock frequency is 1/4 of system clock */
|
||||
SDIO_HOST->MMC_CTL = 0x542 | (0b001 << 3);
|
||||
#endif
|
||||
SDIO_HOST->MMC_INT_MASK = 0x100; //unmask sdio data interrupt.
|
||||
SDIO_HOST->MMC_CRCCTL = 0x00;
|
||||
SDIO_HOST->MMC_TIMEOUTCNT = 0;
|
||||
SDIO_HOST->MMC_BYTECNTL = 0;
|
||||
//Inverse SPI clock polarity for ST7789 screen
|
||||
//SDIO_HOST->MMC_IO_MBCTL |= (1 << 3);
|
||||
|
||||
/* Init callback */
|
||||
DMATransferDoneFuncCb = DMATransferDoneCb;
|
||||
DMATransferDoneArg = arg;
|
||||
}
|
||||
|
||||
static void mmc_sdio_driver_dma_callback(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
|
||||
tls_dma_free(sdio_spi_dma_channel);
|
||||
/* Let's call the user DMATransferDoneFuncCb function if any */
|
||||
if(DMATransferDoneFuncCb)
|
||||
{
|
||||
DMATransferDoneFuncCb(DMATransferDoneArg);
|
||||
}
|
||||
}
|
||||
|
||||
void mmc_sdio_driver_write_dma_async(uint32_t *data, uint32_t dataLengthInBytes)
|
||||
{
|
||||
if (dataLengthInBytes < 4)
|
||||
{
|
||||
APP_LOG_ERROR("send err, data length < 4");
|
||||
return;
|
||||
}
|
||||
|
||||
if (dataLengthInBytes % 4)
|
||||
{
|
||||
// DMA send length must be a multiple of 4
|
||||
dataLengthInBytes -= dataLengthInBytes % 4;
|
||||
// printf("Len not aligned\n");
|
||||
}
|
||||
|
||||
/* Wait for MMC device to be ready to send the data */
|
||||
while (SDIO_HOST->MMC_IO & 0x01);
|
||||
|
||||
SDIO_HOST->BUF_CTL = 0x4000; // disable dma,
|
||||
sdio_spi_dma_channel = tls_dma_request(0, 0);
|
||||
DMA_CHNLCTRL_REG(sdio_spi_dma_channel) = DMA_CHNL_CTRL_CHNL_OFF;
|
||||
DMA_SRCADDR_REG(sdio_spi_dma_channel) = (unsigned int)data;
|
||||
DMA_DESTADDR_REG(sdio_spi_dma_channel) = (unsigned int)SDIO_HOST->DATA_BUF;
|
||||
|
||||
DMA_CTRL_REG(sdio_spi_dma_channel) = DMA_CTRL_SRC_ADDR_INC | DMA_CTRL_DATA_SIZE_WORD | (dataLengthInBytes << 8);
|
||||
DMA_MODE_REG(sdio_spi_dma_channel) = DMA_MODE_SEL_SDIOHOST | DMA_MODE_HARD_MODE;
|
||||
|
||||
tls_dma_irq_register(sdio_spi_dma_channel, &(mmc_sdio_driver_dma_callback), NULL, TLS_DMA_IRQ_TRANSFER_DONE);
|
||||
DMA_CHNLCTRL_REG(sdio_spi_dma_channel) = DMA_CHNL_CTRL_CHNL_ON;
|
||||
|
||||
SDIO_HOST->BUF_CTL = 0xC20; // enable dma, write sd card
|
||||
SDIO_HOST->MMC_INT_SRC |= 0x7ff; // clear all firstly
|
||||
SDIO_HOST->MMC_BYTECNTL = dataLengthInBytes;
|
||||
SDIO_HOST->MMC_IO = 0x01;
|
||||
}
|
||||
|
||||
|
||||
void mmc_sdio_driver_write_one(uint8_t data)
|
||||
{
|
||||
SDIO_HOST->BUF_CTL = 0x4820;
|
||||
SDIO_HOST->DATA_BUF[0] = (uint32_t)data;
|
||||
SDIO_HOST->MMC_BYTECNTL = 1U;
|
||||
/* Start the transfer */
|
||||
SDIO_HOST->MMC_IO = 0x01;
|
||||
/* Wait for MMC device to be done sending the data */
|
||||
while (SDIO_HOST->MMC_IO & 0x01);
|
||||
}
|
||||
|
||||
void mmc_sdio_driver_write(const uint8_t *data, uint16_t dataLengthInBytes)
|
||||
{
|
||||
SDIO_HOST->BUF_CTL = 0x4820;
|
||||
memcpy((void *)SDIO_HOST->DATA_BUF, (void *)data, dataLengthInBytes);
|
||||
SDIO_HOST->MMC_BYTECNTL = dataLengthInBytes;
|
||||
/* Start the transfer */
|
||||
SDIO_HOST->MMC_IO = 0x01;
|
||||
/* Wait for MMC device to be done sending the data */
|
||||
while (SDIO_HOST->MMC_IO & 0x01);
|
||||
}
|
46
src/W800 SDK v1.00.08/app/drivers/mmc_sdio/mmc_sdio.h
Normal file
46
src/W800 SDK v1.00.08/app/drivers/mmc_sdio/mmc_sdio.h
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* MMC peripheral used as DMA capable SPI.
|
||||
*/
|
||||
#ifndef MMC_SDIO_H
|
||||
#define MMC_SDIO_H
|
||||
|
||||
#include "wm_include.h"
|
||||
|
||||
typedef void (*DMATransferDoneCb_t)(void *arg);
|
||||
|
||||
/**
|
||||
* @brief Inits the MMC peripheral in SDIO mode
|
||||
*
|
||||
* @param DMATransferDoneCb a function that will be called when the DMA transfer done IRQ is called
|
||||
* @param arg a pointer to an optional argument passed to the callback function
|
||||
*/
|
||||
void mmc_sdio_driver_periph_init(DMATransferDoneCb_t DMATransferDoneCb, void *arg);
|
||||
|
||||
/**
|
||||
* @brief Sends data to the slave using DMA asynchronously.
|
||||
*
|
||||
* @param data a pointer to a buffer containing the data to transfer
|
||||
* @param dataLengthInBytes the size in bytes of the data to transfer.
|
||||
* Maximum length is 65535 bytes.
|
||||
*/
|
||||
void mmc_sdio_driver_write_dma_async(uint32_t *data, u32 dataLengthInBytes);
|
||||
|
||||
/**
|
||||
* @brief Sends one byte of data to the slave
|
||||
* This function blocks until the data has been sent on the bus.
|
||||
*
|
||||
* @param data the byte to send.
|
||||
*/
|
||||
void mmc_sdio_driver_write_one(uint8_t data);
|
||||
|
||||
/**
|
||||
* @brief Sends data to the slave without using DMA.
|
||||
* This function blocks until all the bytes were sent.
|
||||
*
|
||||
* @param data a pointer to a buffer containing the data to transfer.
|
||||
* @param dataLengthInBytes the size in bytes of the data to transfer.
|
||||
* Maximum length is 512 bytes.
|
||||
*/
|
||||
void mmc_sdio_driver_write(const uint8_t *data, uint16_t dataLengthInBytes);
|
||||
|
||||
#endif //MMC_SDIO_H
|
@ -3,7 +3,8 @@ sinclude $(TOP_DIR)/tools/w800/conf.mk
|
||||
|
||||
ifndef PDIR
|
||||
GEN_LIBS = libusergfx$(LIB_EXT)
|
||||
COMPONENTS_libusergfx = assets/libusergfxassets$(LIB_EXT)
|
||||
COMPONENTS_libusergfx = assets/libusergfxassets$(LIB_EXT) \
|
||||
../drivers/libdrivers$(LIB_EXT)
|
||||
endif
|
||||
|
||||
#DEFINES +=
|
||||
|
@ -13,13 +13,18 @@
|
||||
static lv_color_t lvgl_draw_buffer[LVGL_GFX_BUFFER_SIZE];
|
||||
static lv_disp_draw_buf_t lvgl_draw_buffer_dsc;
|
||||
|
||||
lv_disp_drv_t display_driver;
|
||||
static lv_disp_drv_t display_driver;
|
||||
static LCDConfig_t LCDConfig;
|
||||
|
||||
static void lvgl_display_flush_cb(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
|
||||
{
|
||||
lcd_draw_rect_frame(&LCDConfig, area->x1, area->y1, area->x2 - area->x1 + 1, area->y2 - area->y1 + 1, (uint8_t *)color_p);
|
||||
//lv_disp_flush_ready(disp_drv);
|
||||
/* lv_disp_flush_ready is called in the LCD driver registered callback */
|
||||
}
|
||||
|
||||
static void lcd_draw_finished_cb(void *arg)
|
||||
{
|
||||
lv_disp_flush_ready((lv_disp_drv_t *)arg);
|
||||
}
|
||||
|
||||
struct tm temptm = {0};
|
||||
@ -74,6 +79,7 @@ void gfx_task(void *param)
|
||||
|
||||
/* Initialize the LCD display */
|
||||
lcd_config_init(&LCDConfig);
|
||||
lcd_register_draw_finished_cb(&LCDConfig, &(lcd_draw_finished_cb), &display_driver);
|
||||
|
||||
#if defined(W800)
|
||||
LCDConfig.LCDPWMBacklightPin = WM_IO_PA_07;
|
||||
@ -99,24 +105,26 @@ void gfx_task(void *param)
|
||||
|
||||
lv_port_indev_init();
|
||||
|
||||
/*watch_face_init(&watchFace);
|
||||
watch_face_init(&watchFace);
|
||||
menu_screen_init(&menuScreen);
|
||||
|
||||
watch_face_register_cb(&watchFace, &(date_time_cb));
|
||||
watch_face_create(&watchFace);
|
||||
|
||||
lv_scr_load(watchFace.display);*/
|
||||
//lv_demo_widgets();
|
||||
//lv_demo_benchmark();
|
||||
lv_demo_stress();
|
||||
lv_scr_load(watchFace.display);
|
||||
|
||||
uint8_t aliveCounter = 0;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
lv_timer_handler();
|
||||
tls_os_time_delay(5);
|
||||
|
||||
/* static u32 counter = 0;
|
||||
if(counter++ % 200 == 0)
|
||||
APP_LOG_DEBUG("GFX ALIVE");*/
|
||||
if(++aliveCounter % 200 == 0)
|
||||
{
|
||||
APP_LOG_DEBUG("GFX thread");
|
||||
aliveCounter = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
#ifndef LCD_H
|
||||
#define LCD_H
|
||||
|
||||
#include "wm_include.h"
|
||||
/* Used SOC : W800 or W801 */
|
||||
#define W800
|
||||
/* Display drive controller */
|
||||
#define ILI9341 0
|
||||
#define ST7789V 1
|
||||
#define DISPLAY_CONTROLLER ILI9341
|
||||
//#define DISPLAY_CONTROLLER ST7789V
|
||||
/* Display properties */
|
||||
#define LCD_PIXEL_WIDTH 240
|
||||
#define LCD_PIXEL_HEIGHT 240
|
||||
|
||||
typedef enum LCDDataCommand
|
||||
{
|
||||
LCD_COMMAND = 0,
|
||||
LCD_DATA = 1
|
||||
} LCDDataCommand_e;
|
||||
|
||||
typedef enum LCDSelect
|
||||
{
|
||||
LCD_SELECTED = 0,
|
||||
LCD_RELEASED = 1
|
||||
} LCDSelect_e;
|
||||
|
||||
typedef struct LCDConfig
|
||||
{
|
||||
enum tls_io_name LCDPWMBacklightPin;
|
||||
enum tls_io_name LCDClockPin;
|
||||
enum tls_io_name LCDDataPin;
|
||||
enum tls_io_name LCDChipSelectPin;
|
||||
enum tls_io_name LCDDataCommandPin;
|
||||
enum tls_io_name LCDResetPin;
|
||||
} LCDConfig_t;
|
||||
|
||||
/* Initializes the LCDConfig object to known values */
|
||||
void lcd_config_init(LCDConfig_t * const LCDConfig);
|
||||
|
||||
/* Initializes IOs using the configured LCDConfig object and the LCD display */
|
||||
void lcd_init(LCDConfig_t * const LCDConfig);
|
||||
|
||||
/* Sets the LCD write window area */
|
||||
void lcd_set_window(LCDConfig_t * const LCDConfig, u16 x_start, u16 y_start, u16 x_end, u16 y_end);
|
||||
|
||||
/* Writes the frame to display's internal RAM */
|
||||
void lcd_draw_rect_frame(LCDConfig_t * const LCDConfig, u16 x, u16 y, u16 width, u16 height, u8 *data);
|
||||
|
||||
/* Sets the backlight to the specified brightness value */
|
||||
void lcd_set_backlight(LCDConfig_t * const LCDConfig, u8 brightness);
|
||||
|
||||
/* Sets the chip select pin */
|
||||
void lcd_set_cs(LCDConfig_t * const LCDConfig, LCDSelect_e selected);
|
||||
|
||||
/* Sets the data/command pin state */
|
||||
void lcd_set_data_command(LCDConfig_t * const LCDConfig, LCDDataCommand_e dataCommand);
|
||||
|
||||
/* Issues a reset of the lcd display */
|
||||
void lcd_hardware_reset(LCDConfig_t * const LCDConfig);
|
||||
|
||||
#endif //LCD_H
|
@ -1,76 +0,0 @@
|
||||
#include "lv_port_disp.h"
|
||||
|
||||
// #define USE_PSRAM
|
||||
|
||||
#ifdef USE_PSRAM
|
||||
#include "psram.h"
|
||||
static lv_color_t *lvgl_draw_buff1 = NULL;
|
||||
#if LVGL_PORT_USE_DOUBLE_BUFF
|
||||
static lv_color_t *lvgl_draw_buff2 = NULL;
|
||||
#endif
|
||||
#else
|
||||
static lv_color_t lvgl_draw_buff1[LVGL_PORT_BUFF_SIZE];
|
||||
#if LVGL_PORT_USE_DOUBLE_BUFF
|
||||
static lv_color_t lvgl_draw_buff2[LVGL_PORT_BUFF_SIZE];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
static void disp_flush(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color_t *color_p)
|
||||
{
|
||||
/* 等待上次传输完成 */
|
||||
#if !USE_SPI
|
||||
bsp_lcd_draw_rect_wait();
|
||||
#endif
|
||||
|
||||
/* 启动新的传输 */
|
||||
bsp_lcd_draw_rect(area->x1,area->y1,area->x2 - area->x1 + 1,area->y2 - area->y1 + 1,(uint8_t *)color_p);
|
||||
|
||||
/* 通知lvgl传输已完成 */
|
||||
lv_disp_flush_ready(disp_drv);
|
||||
}
|
||||
|
||||
void lv_port_disp_init()
|
||||
{
|
||||
/* 向lvgl注册缓冲区 */
|
||||
static lv_disp_draw_buf_t draw_buf_dsc; //需要全程生命周期,设置为静态变量
|
||||
|
||||
|
||||
#ifdef USE_PSRAM
|
||||
lvgl_draw_buff1 = dram_heap_malloc(LVGL_PORT_BUFF_SIZE*2);
|
||||
if(lvgl_draw_buff1 == NULL){
|
||||
printf("---> malloc lvgl_draw_buff1 err\n");
|
||||
return;
|
||||
}
|
||||
#if LVGL_PORT_USE_DOUBLE_BUFF
|
||||
lvgl_draw_buff2 = dram_heap_malloc(LVGL_PORT_BUFF_SIZE*2);
|
||||
if(lvgl_draw_buff2 == NULL){
|
||||
printf("---> malloc lvgl_draw_buff2 err\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if LVGL_PORT_USE_DOUBLE_BUFF
|
||||
lv_disp_draw_buf_init(&draw_buf_dsc, lvgl_draw_buff1, lvgl_draw_buff2, LVGL_PORT_BUFF_SIZE);
|
||||
#else
|
||||
lv_disp_draw_buf_init(&draw_buf_dsc, lvgl_draw_buff1, NULL, LVGL_PORT_BUFF_SIZE);
|
||||
#endif
|
||||
|
||||
/* 创建并初始化用于在lvgl中注册显示设备的结构 */
|
||||
static lv_disp_drv_t disp_drv;
|
||||
lv_disp_drv_init(&disp_drv); //使用默认值初始化该结构
|
||||
/* 设置屏幕分辨率 */
|
||||
disp_drv.hor_res = BSP_LCD_X_PIXELS;
|
||||
disp_drv.ver_res = BSP_LCD_Y_PIXELS;
|
||||
disp_drv.rotated = LV_DISP_ROT_180;
|
||||
/* 初始化LCD总线 */
|
||||
bsp_lcd_init();
|
||||
/* 设置显示矩形函数,用于将矩形缓冲区刷新到屏幕上 */
|
||||
disp_drv.flush_cb = disp_flush;
|
||||
/* 设置缓冲区 */
|
||||
disp_drv.draw_buf = &draw_buf_dsc;
|
||||
/* 注册显示设备 */
|
||||
lv_disp_drv_register(&disp_drv);
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
#ifndef __LV_PORT_DISP_H__
|
||||
#define __LV_PORT_DISP_H__
|
||||
#include "lcd_dirty.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
/* lvgl缓冲区大小,单位为像素数 */
|
||||
#define LVGL_PORT_BUFF_SIZE (BSP_LCD_X_PIXELS*BSP_LCD_Y_PIXELS/10) // 1/10屏幕分辨率
|
||||
|
||||
/* 设置是否开启双缓冲 */
|
||||
#define LVGL_PORT_USE_DOUBLE_BUFF 0
|
||||
|
||||
void lv_port_disp_init(void);
|
||||
|
||||
#endif
|
@ -1,22 +0,0 @@
|
||||
#include "lv_port_tick.h"
|
||||
#include "wm_timer.h"
|
||||
|
||||
static void tick_timer_irq(u8 *arg)
|
||||
{
|
||||
lv_tick_inc(LV_TICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
void lv_create_tick(void)
|
||||
{
|
||||
u8 timer_id;
|
||||
struct tls_timer_cfg timer_cfg;
|
||||
|
||||
timer_cfg.unit = TLS_TIMER_UNIT_MS;
|
||||
timer_cfg.timeout = 1;
|
||||
timer_cfg.is_repeat = 1;
|
||||
timer_cfg.callback = (tls_timer_irq_callback)tick_timer_irq;
|
||||
timer_cfg.arg = NULL;
|
||||
timer_id = tls_timer_create(&timer_cfg);
|
||||
tls_timer_start(timer_id);
|
||||
// printf("timer start\n");
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
#ifndef __LV_PORT_TICK_H__
|
||||
#define __LV_PORT_TICK_H__
|
||||
#include "lvgl.h"
|
||||
|
||||
#define LV_TICK_PERIOD_MS 1
|
||||
|
||||
void lv_create_tick(void);
|
||||
|
||||
#endif
|
@ -1,189 +0,0 @@
|
||||
#include <string.h>
|
||||
#include "wm_sdio_host.h"
|
||||
#include "wm_include.h"
|
||||
#include "app_log.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "lvgl.h"
|
||||
|
||||
static u8 sdio_spi_dma_channel = 0xFF;
|
||||
static u32 sdio_spi_dma_buf_size = 0;
|
||||
static u32 *sdio_spi_dma_buf_addr = NULL;
|
||||
static u32 *sdio_spi_dma_temp_buf = NULL;
|
||||
static bool sdio_spi_dma_ready = true;
|
||||
|
||||
static tls_os_sem_t *sdio_spi_dma_ready_flag = NULL;
|
||||
|
||||
void mmc_sdio_driver_periph_init(void)
|
||||
{
|
||||
tls_open_peripheral_clock(TLS_PERIPHERAL_TYPE_SDIO_MASTER);
|
||||
// W800 register manual page 67
|
||||
tls_bitband_write(HR_CLK_RST_CTL, 27, 0);
|
||||
tls_bitband_write(HR_CLK_RST_CTL, 27, 1);
|
||||
// Wait until reset is released
|
||||
while (tls_bitband_read(HR_CLK_RST_CTL, 27) == 0);
|
||||
|
||||
tls_sys_clk sysclk;
|
||||
tls_sys_clk_get(&sysclk);
|
||||
|
||||
// W800 register manual page 179
|
||||
SDIO_HOST->MMC_CARDSEL = 0xC0 | (sysclk.cpuclk / 2 - 1); // enable module, enable mmcclk
|
||||
APP_LOG_DEBUG("cpu clock : %u, mmc_cardsel reg val,addr : %02X, %p ", sysclk.cpuclk, SDIO_HOST->MMC_CARDSEL, &SDIO_HOST->MMC_CARDSEL);
|
||||
#if (0) // Clock frequency is 1/2 of system clock
|
||||
SDIO_HOST->MMC_CTL = 0x542 | 0 << 3; // auto transfer, mmc mode.
|
||||
#else /* Clock frequency is 1/4 of system clock */
|
||||
SDIO_HOST->MMC_CTL = 0x542 | (0b000 << 3); // 001
|
||||
#endif
|
||||
SDIO_HOST->MMC_INT_MASK = 0x100; //unmask sdio data interrupt.
|
||||
SDIO_HOST->MMC_CRCCTL = 0x00;
|
||||
SDIO_HOST->MMC_TIMEOUTCNT = 0;
|
||||
SDIO_HOST->MMC_BYTECNTL = 0;
|
||||
|
||||
// Create a semaphore
|
||||
tls_os_sem_create(&sdio_spi_dma_ready_flag, 1);
|
||||
}
|
||||
|
||||
static void mmc_sdio_driver_dma_callback(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
// printf("sdio_dma_callback\n");
|
||||
// printf("--->buf_size:%d\n", sdio_spi_dma_buf_size);
|
||||
/*if(sdio_spi_dma_buf_size > 0)
|
||||
{
|
||||
sdio_spi_dma_buf_addr += 65532/4;
|
||||
DMA_CHNLCTRL_REG(sdio_spi_dma_channel) = DMA_CHNL_CTRL_CHNL_OFF;
|
||||
|
||||
DMA_SRCADDR_REG(sdio_spi_dma_channel) = (unsigned int)sdio_spi_dma_buf_addr;
|
||||
DMA_DESTADDR_REG(sdio_spi_dma_channel) = (unsigned int)SDIO_HOST->DATA_BUF;
|
||||
|
||||
u32 bufsize = sdio_spi_dma_buf_size;
|
||||
if(bufsize > 65532){
|
||||
bufsize = 65532;
|
||||
}
|
||||
sdio_spi_dma_buf_size -= bufsize;
|
||||
|
||||
DMA_CTRL_REG(sdio_spi_dma_channel) = DMA_CTRL_SRC_ADDR_INC | DMA_CTRL_DATA_SIZE_WORD | (bufsize << 8);
|
||||
DMA_MODE_REG(sdio_spi_dma_channel) = DMA_MODE_SEL_SDIOHOST | DMA_MODE_HARD_MODE;
|
||||
|
||||
DMA_CHNLCTRL_REG(sdio_spi_dma_channel) = DMA_CHNL_CTRL_CHNL_ON;
|
||||
|
||||
SDIO_HOST->BUF_CTL = 0xC20; //enable dma, write sd card
|
||||
SDIO_HOST->MMC_INT_SRC |= 0x7ff; // clear all firstly
|
||||
SDIO_HOST->MMC_BYTECNTL = bufsize;
|
||||
SDIO_HOST->MMC_IO = 0x01;
|
||||
}
|
||||
else*/
|
||||
{
|
||||
tls_dma_free(sdio_spi_dma_channel);
|
||||
extern lv_disp_drv_t display_driver;
|
||||
lv_disp_flush_ready(&display_driver);
|
||||
//tls_os_sem_release(sdio_spi_dma_ready_flag);
|
||||
|
||||
//tls_mem_free(sdio_spi_dma_temp_buf);
|
||||
//free(sdio_spi_dma_temp_buf);
|
||||
// 等待信号量 直到上一次DMA数据发送完成
|
||||
// sdio_spi_dma_ready = true;
|
||||
// printf("--->tls_os_sem_release [%s:%d]\r\n",__func__,__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
//static u32 tmpbuff[5760];
|
||||
|
||||
void mmc_sdio_driver_write_dma_async(u32 *data, u32 dataLengthInBytes)
|
||||
{
|
||||
// Wait for the semaphore until the last DMA data transmission is completed
|
||||
// printf("--->tls_os_sem_acquire [%s:%d]\r\n",__func__,__LINE__);
|
||||
/*tls_os_sem_acquire(sdio_spi_dma_ready_flag, 0);
|
||||
sdio_spi_dma_ready = false;*/
|
||||
// printf("--->%s:%d\r\n",__func__,__LINE__);
|
||||
|
||||
// printf("--->w buf_size:%d\n", len);
|
||||
if (dataLengthInBytes < 4)
|
||||
{
|
||||
printf("send err\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (dataLengthInBytes % 4)
|
||||
{
|
||||
// len += (4 - (len%4)); // DMA send length must be a multiple of 4
|
||||
dataLengthInBytes -= dataLengthInBytes % 4;
|
||||
// printf("Len not aligned\n");
|
||||
}
|
||||
|
||||
//sdio_spi_dma_temp_buf = tls_mem_alloc(dataLengthInBytes);
|
||||
/*sdio_spi_dma_temp_buf = malloc(dataLengthInBytes);
|
||||
|
||||
if (sdio_spi_dma_temp_buf == NULL)
|
||||
{
|
||||
printf("---> malloc sdio_spi_dma_temp_buf err\n");
|
||||
return;
|
||||
}
|
||||
memcpy(sdio_spi_dma_temp_buf, data, dataLengthInBytes);
|
||||
|
||||
sdio_spi_dma_buf_addr = sdio_spi_dma_temp_buf;*/
|
||||
//memcpy(tmpbuff, data, dataLengthInBytes);
|
||||
sdio_spi_dma_buf_size = dataLengthInBytes;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if ((SDIO_HOST->MMC_IO & 0x01) == 0x00)
|
||||
break;
|
||||
}
|
||||
|
||||
SDIO_HOST->BUF_CTL = 0x4000; // disable dma,
|
||||
sdio_spi_dma_channel = tls_dma_request(0, 0);
|
||||
DMA_CHNLCTRL_REG(sdio_spi_dma_channel) = DMA_CHNL_CTRL_CHNL_OFF;
|
||||
DMA_SRCADDR_REG(sdio_spi_dma_channel) = (unsigned int)data;//sdio_spi_dma_buf_addr;
|
||||
DMA_DESTADDR_REG(sdio_spi_dma_channel) = (unsigned int)SDIO_HOST->DATA_BUF;
|
||||
/*u32 bufsize = sdio_spi_dma_buf_size;
|
||||
if (bufsize > 65532)
|
||||
{
|
||||
bufsize = 65532;
|
||||
}
|
||||
sdio_spi_dma_buf_size -= bufsize;*/
|
||||
|
||||
DMA_CTRL_REG(sdio_spi_dma_channel) = DMA_CTRL_SRC_ADDR_INC | DMA_CTRL_DATA_SIZE_WORD | (sdio_spi_dma_buf_size << 8);
|
||||
DMA_MODE_REG(sdio_spi_dma_channel) = DMA_MODE_SEL_SDIOHOST | DMA_MODE_HARD_MODE;
|
||||
|
||||
tls_dma_irq_register(sdio_spi_dma_channel, &(mmc_sdio_driver_dma_callback), NULL, TLS_DMA_IRQ_TRANSFER_DONE);
|
||||
DMA_CHNLCTRL_REG(sdio_spi_dma_channel) = DMA_CHNL_CTRL_CHNL_ON;
|
||||
|
||||
SDIO_HOST->BUF_CTL = 0xC20; // enable dma, write sd card
|
||||
SDIO_HOST->MMC_INT_SRC |= 0x7ff; // clear all firstly
|
||||
SDIO_HOST->MMC_BYTECNTL = sdio_spi_dma_buf_size;//bufsize;
|
||||
SDIO_HOST->MMC_IO = 0x01;
|
||||
sdio_spi_dma_buf_size = 0;
|
||||
}
|
||||
|
||||
|
||||
void mmc_sdio_driver_write_one(u8 byte)
|
||||
{
|
||||
SDIO_HOST->BUF_CTL = 0x4820;
|
||||
SDIO_HOST->DATA_BUF[0] = byte;
|
||||
|
||||
SDIO_HOST->MMC_BYTECNTL = 1;
|
||||
SDIO_HOST->MMC_IO = 0x01;
|
||||
while (1) {
|
||||
if ((SDIO_HOST->MMC_IO & 0x01) == 0x00)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void mmc_sdio_driver_write(const u8 * bytes, u16 len)
|
||||
{
|
||||
SDIO_HOST->BUF_CTL = 0x4820;
|
||||
memcpy(SDIO_HOST->DATA_BUF, bytes, len);
|
||||
|
||||
SDIO_HOST->MMC_BYTECNTL = len;
|
||||
SDIO_HOST->MMC_IO = 0x01;
|
||||
while (SDIO_HOST->MMC_IO & 0x01);
|
||||
}
|
||||
|
||||
void mmc_sdio_driver_wait_write_dma_ready(void)
|
||||
{
|
||||
while(!sdio_spi_dma_ready)
|
||||
{
|
||||
// Yield some time to FreeRTOS to schedule an other task meanwhile
|
||||
tls_os_time_delay(pdMS_TO_TICKS(1));
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
#ifndef MMC_SDIO_H
|
||||
#define MMC_SDIO_H
|
||||
|
||||
#include "wm_include.h"
|
||||
|
||||
/* Inits the MMC peripheral in SDIO mode */
|
||||
void mmc_sdio_driver_periph_init(void);
|
||||
|
||||
/* Sends the data to the slave using DMA in an asynchronous manner */
|
||||
void mmc_sdio_driver_write_dma_async(u32 *data, u32 dataLengthInBytes);
|
||||
|
||||
/* Sends one byte of data to the slave */
|
||||
void mmc_sdio_driver_write_one(u8 byte);
|
||||
|
||||
void mmc_sdio_driver_write(const u8 * bytes, u16 len);
|
||||
|
||||
/* Blocks the current task until the write through DMA is available again */
|
||||
void mmc_sdio_driver_wait_write_dma_ready(void);
|
||||
|
||||
#endif //MMC_SDIO_H
|
@ -1,236 +0,0 @@
|
||||
#include "sdio_spi_driver.h"
|
||||
#include "wm_sdio_host.h"
|
||||
#include "wm_cpu.h"
|
||||
#include "wm_dma.h"
|
||||
#include "wm_pmu.h"
|
||||
#include <string.h>
|
||||
#include "sdio_spi_driver.h"
|
||||
|
||||
// #define USE_PSRAM
|
||||
|
||||
#ifdef USE_PSRAM
|
||||
#include "psram.h"
|
||||
#endif
|
||||
|
||||
static u8 sdio_spi_dma_channel = 0xFF;
|
||||
static u32 sdio_spi_dma_buf_size = 0;
|
||||
static u32 *sdio_spi_dma_buf_addr = NULL;
|
||||
static u32 *sdio_spi_dma_temp_buf = NULL;
|
||||
|
||||
static tls_os_sem_t *sdio_spi_dma_ready_flag = NULL;
|
||||
|
||||
static bool sdio_spi_dma_ready = true;
|
||||
|
||||
|
||||
void init_sdio_spi_mode()
|
||||
{
|
||||
// tls_io_cfg_set(WM_IO_PA_09, WM_IO_OPTION1);/*CK*/
|
||||
// tls_io_cfg_set(WM_IO_PA_10, WM_IO_OPTION1);/*CMD*/
|
||||
tls_open_peripheral_clock(TLS_PERIPHERAL_TYPE_SDIO_MASTER);
|
||||
tls_bitband_write(HR_CLK_RST_CTL, 27, 0);
|
||||
tls_bitband_write(HR_CLK_RST_CTL, 27, 1);
|
||||
while (tls_bitband_read(HR_CLK_RST_CTL, 27) == 0);
|
||||
tls_sys_clk sysclk;
|
||||
tls_sys_clk_get(&sysclk);
|
||||
|
||||
SDIO_HOST->MMC_CARDSEL = 0xC0 | (sysclk.cpuclk / 2 - 1); // enable module, enable mmcclk
|
||||
printf("SDIO_HOST : %02X\ncpu clk : %d\n", SDIO_HOST->MMC_CARDSEL, sysclk.cpuclk);
|
||||
#if (0) // 时钟频率为系统时钟 1/2
|
||||
SDIO_HOST->MMC_CTL = 0x542 | 0 << 3;// auto transfer, mmc mode.
|
||||
#else // 时钟频率为系统时钟 1/4
|
||||
SDIO_HOST->MMC_CTL = 0x542 | (0b001 << 3); // 001
|
||||
#endif
|
||||
SDIO_HOST->MMC_INT_MASK = 0x100; // unmask sdio data interrupt.
|
||||
SDIO_HOST->MMC_CRCCTL = 0x00;
|
||||
SDIO_HOST->MMC_TIMEOUTCNT = 0;
|
||||
SDIO_HOST->MMC_BYTECNTL = 0;
|
||||
|
||||
// 创建信号量
|
||||
tls_os_sem_create(&sdio_spi_dma_ready_flag, 1);
|
||||
}
|
||||
|
||||
|
||||
static int sdio_spi_dma_cfg(u32*mbuf,u32 bufsize,u8 dir)
|
||||
{
|
||||
int ch;
|
||||
u32 addr_inc = 0;
|
||||
|
||||
ch = tls_dma_request(0, 0);
|
||||
DMA_CHNLCTRL_REG(ch) = DMA_CHNL_CTRL_CHNL_OFF;
|
||||
|
||||
if(dir)
|
||||
{
|
||||
DMA_SRCADDR_REG(ch) = (unsigned int)mbuf;
|
||||
DMA_DESTADDR_REG(ch) = (unsigned int)SDIO_HOST->DATA_BUF;
|
||||
addr_inc = DMA_CTRL_SRC_ADDR_INC;
|
||||
}
|
||||
else
|
||||
{
|
||||
DMA_SRCADDR_REG(ch) = (unsigned int)SDIO_HOST->DATA_BUF;
|
||||
DMA_DESTADDR_REG(ch) = (unsigned int)mbuf;
|
||||
addr_inc =DMA_CTRL_DEST_ADDR_INC;
|
||||
}
|
||||
|
||||
DMA_CTRL_REG(ch) = addr_inc | DMA_CTRL_DATA_SIZE_WORD | (bufsize << 8);
|
||||
DMA_MODE_REG(ch) = DMA_MODE_SEL_SDIOHOST | DMA_MODE_HARD_MODE;
|
||||
|
||||
// tls_dma_irq_register(ch, (void (*))sdio_dma_callback, NULL, TLS_DMA_IRQ_TRANSFER_DONE);
|
||||
DMA_CHNLCTRL_REG(ch) = DMA_CHNL_CTRL_CHNL_ON;
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
void sdio_spi_put(u8 d)
|
||||
{
|
||||
SDIO_HOST->BUF_CTL = 0x4820;
|
||||
SDIO_HOST->DATA_BUF[0] = d;
|
||||
|
||||
SDIO_HOST->MMC_BYTECNTL = 1;
|
||||
SDIO_HOST->MMC_IO = 0x01;
|
||||
while (1) {
|
||||
if ((SDIO_HOST->MMC_IO & 0x01) == 0x00)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void write_sdio_spi_dma(u32* data, u32 len)
|
||||
{
|
||||
while(1){
|
||||
if ((SDIO_HOST->MMC_IO & 0x01) == 0x00)
|
||||
break;
|
||||
}
|
||||
u32 offset=0;
|
||||
while(len>0){
|
||||
int datalen=len;
|
||||
if(len>0xfffc)
|
||||
datalen=0xfffc;
|
||||
len-=datalen;
|
||||
|
||||
SDIO_HOST->BUF_CTL = 0x4000; //disable dma,
|
||||
sdio_spi_dma_channel = sdio_spi_dma_cfg((u32 *) data+offset, datalen, 1);
|
||||
SDIO_HOST->BUF_CTL = 0xC20; //enable dma, write sd card
|
||||
SDIO_HOST->MMC_INT_SRC |= 0x7ff; // clear all firstly
|
||||
SDIO_HOST->MMC_BYTECNTL = datalen;
|
||||
SDIO_HOST->MMC_IO = 0x01;
|
||||
offset+=datalen/4;
|
||||
while(1){
|
||||
if ((SDIO_HOST->BUF_CTL & 0x400) == 0x00)
|
||||
break;
|
||||
}
|
||||
tls_dma_free(sdio_spi_dma_channel);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void sdio_dma_callback(void)
|
||||
{
|
||||
// printf("sdio_dma_callback\n");
|
||||
// printf("--->buf_size:%d\n", sdio_spi_dma_buf_size);
|
||||
if(sdio_spi_dma_buf_size > 0)
|
||||
{
|
||||
sdio_spi_dma_buf_addr += 65532/4;
|
||||
DMA_CHNLCTRL_REG(sdio_spi_dma_channel) = DMA_CHNL_CTRL_CHNL_OFF;
|
||||
|
||||
DMA_SRCADDR_REG(sdio_spi_dma_channel) = (unsigned int)sdio_spi_dma_buf_addr;
|
||||
DMA_DESTADDR_REG(sdio_spi_dma_channel) = (unsigned int)SDIO_HOST->DATA_BUF;
|
||||
|
||||
u32 bufsize = sdio_spi_dma_buf_size;
|
||||
if(bufsize > 65532){
|
||||
bufsize = 65532;
|
||||
}
|
||||
sdio_spi_dma_buf_size -= bufsize;
|
||||
|
||||
DMA_CTRL_REG(sdio_spi_dma_channel) = DMA_CTRL_SRC_ADDR_INC | DMA_CTRL_DATA_SIZE_WORD | (bufsize << 8);
|
||||
DMA_MODE_REG(sdio_spi_dma_channel) = DMA_MODE_SEL_SDIOHOST | DMA_MODE_HARD_MODE;
|
||||
|
||||
DMA_CHNLCTRL_REG(sdio_spi_dma_channel) = DMA_CHNL_CTRL_CHNL_ON;
|
||||
|
||||
SDIO_HOST->BUF_CTL = 0xC20; //enable dma, write sd card
|
||||
SDIO_HOST->MMC_INT_SRC |= 0x7ff; // clear all firstly
|
||||
SDIO_HOST->MMC_BYTECNTL = bufsize;
|
||||
SDIO_HOST->MMC_IO = 0x01;
|
||||
}
|
||||
else
|
||||
{
|
||||
tls_dma_free(sdio_spi_dma_channel);
|
||||
tls_os_sem_release(sdio_spi_dma_ready_flag);
|
||||
#ifdef USE_PSRAM
|
||||
dram_heap_free(sdio_spi_dma_temp_buf);
|
||||
#else
|
||||
tls_mem_free(sdio_spi_dma_temp_buf);
|
||||
#endif
|
||||
// 等待信号量 直到上一次DMA数据发送完成
|
||||
sdio_spi_dma_ready = true;
|
||||
// printf("--->tls_os_sem_release [%s:%d]\r\n",__func__,__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
void wait_sdio_spi_dma_ready()
|
||||
{
|
||||
while(!sdio_spi_dma_ready){
|
||||
tls_os_time_delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
void write_sdio_spi_dma_async(u32* data, u32 len)
|
||||
{
|
||||
// 等待信号量 直到上一次DMA数据发送完成
|
||||
// printf("--->tls_os_sem_acquire [%s:%d]\r\n",__func__,__LINE__);
|
||||
tls_os_sem_acquire(sdio_spi_dma_ready_flag, 0);
|
||||
sdio_spi_dma_ready = false;
|
||||
// printf("--->%s:%d\r\n",__func__,__LINE__);
|
||||
|
||||
// printf("--->w buf_size:%d\n", len);
|
||||
if(len<4){
|
||||
printf("send err\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(len%4)
|
||||
{
|
||||
//len += (4 - (len%4)); // dma发送长度必须为4的倍数
|
||||
len -= len%4;
|
||||
//printf("Len not aligned\n");
|
||||
}
|
||||
#ifdef USE_PSRAM
|
||||
sdio_spi_dma_temp_buf = dram_heap_malloc(len);
|
||||
#else
|
||||
sdio_spi_dma_temp_buf = tls_mem_alloc(len);
|
||||
#endif
|
||||
if(sdio_spi_dma_temp_buf == NULL){
|
||||
printf("---> malloc sdio_spi_dma_temp_buf err\n");
|
||||
return;
|
||||
}
|
||||
memcpy(sdio_spi_dma_temp_buf, data, len);
|
||||
|
||||
sdio_spi_dma_buf_addr = sdio_spi_dma_temp_buf;
|
||||
sdio_spi_dma_buf_size = len;
|
||||
|
||||
while(1){
|
||||
if ((SDIO_HOST->MMC_IO & 0x01) == 0x00)
|
||||
break;
|
||||
}
|
||||
|
||||
SDIO_HOST->BUF_CTL = 0x4000; //disable dma,
|
||||
sdio_spi_dma_channel = tls_dma_request(0, 0);
|
||||
DMA_CHNLCTRL_REG(sdio_spi_dma_channel) = DMA_CHNL_CTRL_CHNL_OFF;
|
||||
DMA_SRCADDR_REG(sdio_spi_dma_channel) = (unsigned int)sdio_spi_dma_buf_addr;
|
||||
DMA_DESTADDR_REG(sdio_spi_dma_channel) = (unsigned int)SDIO_HOST->DATA_BUF;
|
||||
u32 bufsize = sdio_spi_dma_buf_size;
|
||||
if(bufsize > 65532){
|
||||
bufsize = 65532;
|
||||
}
|
||||
sdio_spi_dma_buf_size -= bufsize;
|
||||
|
||||
DMA_CTRL_REG(sdio_spi_dma_channel) = DMA_CTRL_SRC_ADDR_INC | DMA_CTRL_DATA_SIZE_WORD | (bufsize << 8);
|
||||
DMA_MODE_REG(sdio_spi_dma_channel) = DMA_MODE_SEL_SDIOHOST | DMA_MODE_HARD_MODE;
|
||||
|
||||
tls_dma_irq_register(sdio_spi_dma_channel, (void (*))sdio_dma_callback, NULL, TLS_DMA_IRQ_TRANSFER_DONE);
|
||||
DMA_CHNLCTRL_REG(sdio_spi_dma_channel) = DMA_CHNL_CTRL_CHNL_ON;
|
||||
|
||||
SDIO_HOST->BUF_CTL = 0xC20; //enable dma, write sd card
|
||||
SDIO_HOST->MMC_INT_SRC |= 0x7ff; // clear all firstly
|
||||
SDIO_HOST->MMC_BYTECNTL = bufsize;
|
||||
SDIO_HOST->MMC_IO = 0x01;
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
#ifndef __SDIO_SPI_DRIVER_H__
|
||||
#define __SDIO_SPI_DRIVER_H__
|
||||
#include "wm_include.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void init_sdio_spi_mode();
|
||||
|
||||
void sdio_spi_put(u8 d);
|
||||
|
||||
void write_sdio_spi_dma(u32* data,u32 len);
|
||||
|
||||
void write_sdio_spi_dma_async(u32* data,u32 len);
|
||||
|
||||
void wait_sdio_spi_dma_ready();
|
||||
|
||||
#endif
|
@ -49,8 +49,7 @@
|
||||
#define LV_MEM_CUSTOM 0
|
||||
#if LV_MEM_CUSTOM == 0
|
||||
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
|
||||
//#define LV_MEM_SIZE (30 * 1024U) /*[bytes]*/
|
||||
#define LV_MEM_SIZE (48 * 1024U)
|
||||
#define LV_MEM_SIZE (30 * 1024U) /*[bytes]*/
|
||||
|
||||
/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
|
||||
#define LV_MEM_ADR 0 /*0: unused*/
|
||||
@ -220,7 +219,7 @@
|
||||
*-----------*/
|
||||
|
||||
/*Enable the log module*/
|
||||
#define LV_USE_LOG 0
|
||||
#define LV_USE_LOG 1
|
||||
#if LV_USE_LOG
|
||||
|
||||
/*How important log should be added:
|
||||
@ -718,14 +717,14 @@
|
||||
*==================*/
|
||||
|
||||
/*Enable the examples to be built with the library*/
|
||||
#define LV_BUILD_EXAMPLES 1
|
||||
#define LV_BUILD_EXAMPLES 0
|
||||
|
||||
/*===================
|
||||
* DEMO USAGE
|
||||
====================*/
|
||||
|
||||
/*Show some widget. It might be required to increase `LV_MEM_SIZE` */
|
||||
#define LV_USE_DEMO_WIDGETS 1
|
||||
#define LV_USE_DEMO_WIDGETS 0
|
||||
#if LV_USE_DEMO_WIDGETS
|
||||
#define LV_DEMO_WIDGETS_SLIDESHOW 0
|
||||
#endif
|
||||
@ -734,14 +733,14 @@
|
||||
#define LV_USE_DEMO_KEYPAD_AND_ENCODER 0
|
||||
|
||||
/*Benchmark your system*/
|
||||
#define LV_USE_DEMO_BENCHMARK 1
|
||||
#define LV_USE_DEMO_BENCHMARK 0
|
||||
#if LV_USE_DEMO_BENCHMARK
|
||||
/*Use RGB565A8 images with 16 bit color depth instead of ARGB8565*/
|
||||
#define LV_DEMO_BENCHMARK_RGB565A8 0
|
||||
#endif
|
||||
|
||||
/*Stress test for LVGL*/
|
||||
#define LV_USE_DEMO_STRESS 1
|
||||
#define LV_USE_DEMO_STRESS 0
|
||||
|
||||
/*Music player demo*/
|
||||
#define LV_USE_DEMO_MUSIC 0
|
||||
|
@ -173,7 +173,8 @@ void tls_dma_irq_clr(unsigned char ch, unsigned char flags)
|
||||
* @return None
|
||||
*
|
||||
* @note None
|
||||
*/void tls_dma_irq_register(unsigned char ch, void (*callback)(void *p), void *arg, unsigned char flags)
|
||||
*/
|
||||
void tls_dma_irq_register(unsigned char ch, void (*callback)(void *p), void *arg, unsigned char flags)
|
||||
{
|
||||
unsigned int mask;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user