mirror of
https://github.com/Ai-Thinker-Open/Ai-Thinker-Open_RTL8710BX_ALIOS_SDK.git
synced 2026-07-14 05:55:38 +00:00
rel_1.6.0 init
This commit is contained in:
commit
27b3e2883d
19359 changed files with 8093121 additions and 0 deletions
11
Living_SDK/board/starterkit/atcmd_config_platform.h
Normal file
11
Living_SDK/board/starterkit/atcmd_config_platform.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
|
||||
*/
|
||||
|
||||
#ifndef _ATCMD_CONFIG_PLATFORM_H_
|
||||
#define _ATCMD_CONFIG_PLATFORM_H_
|
||||
|
||||
// AT uart
|
||||
#define AT_UART_PORT 1
|
||||
|
||||
#endif
|
||||
40
Living_SDK/board/starterkit/board.c
Executable file
40
Living_SDK/board/starterkit/board.c
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
#include "hal/soc/soc.h"
|
||||
#include <aos/kernel.h>
|
||||
|
||||
/* Logic partition on flash devices */
|
||||
hal_logic_partition_t hal_partitions[HAL_PARTITION_MAX];
|
||||
|
||||
static void board_partition_init()
|
||||
{
|
||||
hal_partitions[HAL_PARTITION_APPLICATION].partition_owner = HAL_FLASH_EMBEDDED;
|
||||
hal_partitions[HAL_PARTITION_APPLICATION].partition_description = "Application";
|
||||
hal_partitions[HAL_PARTITION_APPLICATION].partition_start_addr = 0x08000000;
|
||||
hal_partitions[HAL_PARTITION_APPLICATION].partition_length = 0x3C000; //128k bytes
|
||||
hal_partitions[HAL_PARTITION_APPLICATION].partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN;
|
||||
|
||||
hal_partitions[HAL_PARTITION_PARAMETER_1].partition_owner = HAL_FLASH_EMBEDDED;
|
||||
hal_partitions[HAL_PARTITION_PARAMETER_1].partition_description = "PARAMETER1";
|
||||
hal_partitions[HAL_PARTITION_PARAMETER_1].partition_start_addr = 0x0803C000;
|
||||
hal_partitions[HAL_PARTITION_PARAMETER_1].partition_length = 0x1000; // 4k bytes
|
||||
hal_partitions[HAL_PARTITION_PARAMETER_1].partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN;
|
||||
|
||||
hal_partitions[HAL_PARTITION_PARAMETER_2].partition_owner = HAL_FLASH_EMBEDDED;
|
||||
hal_partitions[HAL_PARTITION_PARAMETER_2].partition_description = "PARAMETER2";
|
||||
hal_partitions[HAL_PARTITION_PARAMETER_2].partition_start_addr = 0x0803D000;
|
||||
hal_partitions[HAL_PARTITION_PARAMETER_2].partition_length = 0x2000; //8k bytes
|
||||
hal_partitions[HAL_PARTITION_PARAMETER_2].partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN;
|
||||
|
||||
hal_partitions[HAL_PARTITION_PARAMETER_4].partition_owner = HAL_FLASH_EMBEDDED;
|
||||
hal_partitions[HAL_PARTITION_PARAMETER_4].partition_description = "PARAMETER4";
|
||||
hal_partitions[HAL_PARTITION_PARAMETER_4].partition_start_addr = 0x0803F000;
|
||||
hal_partitions[HAL_PARTITION_PARAMETER_4].partition_length = 0x1000; //4k bytes
|
||||
hal_partitions[HAL_PARTITION_PARAMETER_4].partition_options = PAR_OPT_READ_EN | PAR_OPT_WRITE_EN;
|
||||
}
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
board_partition_init();
|
||||
|
||||
board_cli_init();
|
||||
|
||||
}
|
||||
10
Living_SDK/board/starterkit/board.h
Normal file
10
Living_SDK/board/starterkit/board.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#define HARDWARE_REVISION "V1.0"
|
||||
#define MODEL "STM32L4"
|
||||
|
||||
#ifdef BOOTLOADER
|
||||
#define STDIO_UART 0
|
||||
#define STDIO_UART_BUADRATE 115200
|
||||
#else
|
||||
#define STDIO_UART 0
|
||||
#define STDIO_UART_BUADRATE 115200
|
||||
#endif
|
||||
217
Living_SDK/board/starterkit/board_cli.c
Normal file
217
Living_SDK/board/starterkit/board_cli.c
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <aos/aos.h>
|
||||
#include <atparser.h>
|
||||
|
||||
|
||||
#define STARTERKIT_WIFI_MODULE_FOTA "AT+FOTA"
|
||||
#define FOTA_OOB_PREFIX "+FOTAEVENT:"
|
||||
#define FOTA_OOB_POSTFIX "\r\n"
|
||||
|
||||
typedef struct modulefotastatus {
|
||||
int ret;
|
||||
aos_sem_t stmoduelfotasem;
|
||||
} fotastatus_t;
|
||||
|
||||
static fotastatus_t fota_status;
|
||||
|
||||
static int module_fota_firmware_size_check(char *pcsize)
|
||||
{
|
||||
int i = 0;
|
||||
if (NULL == pcsize){
|
||||
printf("invalid input at $s %d \r\n", __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*It's impossible that the size of firmware can over 10e9*/
|
||||
if (strlen(pcsize) > 10) {
|
||||
printf("invalid lenth %s at %s %d \r\n ", pcsize, __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < strlen(pcsize); i++){
|
||||
if (pcsize[i] < '0' || pcsize[i] > '9'){
|
||||
printf("invalid lenth %s at %s %d \r\n ", pcsize, __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int module_fota_firmware_md5_check(char *pcmd5)
|
||||
{
|
||||
int i = 0;
|
||||
if (NULL == pcmd5){
|
||||
printf("invalid input at $s %d \r\n", __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*It's impossible that the length of md5 value can over 64*/
|
||||
if (strlen(pcmd5) > 64) {
|
||||
printf("invalid lenth %s at %s %d \r\n ", pcmd5, __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < strlen(pcmd5); i++){
|
||||
if (!((pcmd5[i] >= '0' && pcmd5[i] <= '9')
|
||||
|| (pcmd5[i] >= 'a' && pcmd5[i] <= 'f')
|
||||
|| (pcmd5[i] >= 'A' && pcmd5[i] <= 'F'))){
|
||||
printf("invalid lenth %s at %s %d \r\n ", pcmd5, __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int wifi_module_fota(char *pcsize, char *pcversion, char *pcurl, char *pcmd5)
|
||||
{
|
||||
char *pcatcmd = NULL;
|
||||
char out[64] = {0};
|
||||
int cmdlen = 0;
|
||||
int ret = 0;
|
||||
|
||||
if (NULL == pcsize || NULL == pcversion || NULL == pcurl || NULL == pcmd5){
|
||||
printf("invalid input at %s %d \r\n", __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pcatcmd = aos_malloc(1024);
|
||||
if (NULL == pcatcmd){
|
||||
printf("fail to malloc memory at %s %d \r\n", __FILE__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(pcatcmd, 0, 1024);
|
||||
|
||||
cmdlen = snprintf(pcatcmd, 1024, "%s=%s,%s,%s,%s", STARTERKIT_WIFI_MODULE_FOTA, pcsize,
|
||||
pcversion, pcurl, pcmd5);
|
||||
if (cmdlen >= 1024){
|
||||
printf("invalid cmd at %s %d \r\n", __FILE__, __LINE__);
|
||||
ret = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = at.send_raw(pcatcmd, out, sizeof(out));
|
||||
LOGD(TAG, "The AT response is: %s", out);
|
||||
if (strstr(out, AT_RECV_FAIL_POSTFIX) != NULL || ret != 0) {
|
||||
printf("%s %d failed", __func__, __LINE__);
|
||||
ret = -1;
|
||||
goto end;
|
||||
}
|
||||
|
||||
aos_sem_wait(&fota_status.stmoduelfotasem , AOS_WAIT_FOREVER);
|
||||
if (fota_status.ret != 0){
|
||||
printf("module fota failed at %s %d \r\n", __FILE__, __LINE__);
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
end:
|
||||
aos_free(pcatcmd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void handle_module_fota_cmd(char *pwbuf, int blen, int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
char *pcsize = NULL;
|
||||
char *pcversion = NULL;
|
||||
char *pcurl = NULL;
|
||||
char *pcmd5 = NULL;
|
||||
|
||||
if (argc != 5 || NULL == argv){
|
||||
aos_cli_printf("invalid cmd at %s %d \r\n", __FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
pcsize = argv[1];
|
||||
/*or check if atoi(pcsize) <= 0, is invalid*/
|
||||
if (module_fota_firmware_size_check(pcsize) != 0){
|
||||
printf("invalid cmd at %s %d \r\n", __FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
pcversion = argv[2];
|
||||
if (strlen(pcversion) >= 64){
|
||||
printf("invalid cmd at %s %d \r\n", __FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
pcurl = argv[3];
|
||||
if (strlen(pcversion) >= 512){
|
||||
printf("invalid cmd at %s %d \r\n", __FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
pcmd5 = argv[4];
|
||||
if (module_fota_firmware_md5_check(pcmd5) != 0){
|
||||
printf("invalid cmd at %s %d \r\n", __FILE__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("It's going to start wifi module fota it will cost several minutes. Please be patient, and Do not power off the module or reboot befor ota is finished. \r\n");
|
||||
ret = wifi_module_fota(pcsize, pcversion, pcurl, pcmd5);
|
||||
if (ret != 0){
|
||||
printf("module-ota excute failed \r\n");
|
||||
}else{
|
||||
printf("module-ota excute successed \r\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
struct cli_command module_ota_cli_cmd[] = {
|
||||
{
|
||||
.name = "module-ota",
|
||||
.help = "module-ota size version url md5-value",
|
||||
.function = handle_module_fota_cmd
|
||||
}
|
||||
};
|
||||
|
||||
void fota_event_handler(void *arg, char *buf, int buflen)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (NULL == buf || 0 == buflen){
|
||||
printf("invalid input %s %d \r\n", __FILE__, __LINE__);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (strstr(buf, AT_RECV_FAIL_POSTFIX) != NULL){
|
||||
printf("module-fota result is %s \r\n", buf);
|
||||
goto end;
|
||||
}
|
||||
ret = 0;
|
||||
end:
|
||||
fota_status.ret = ret;
|
||||
aos_sem_signal(&fota_status.stmoduelfotasem);
|
||||
}
|
||||
|
||||
static void wifi_event_handler(input_event_t *event, void *priv_data)
|
||||
{
|
||||
if (event->type != EV_WIFI)
|
||||
return;
|
||||
|
||||
if (event->code == CODE_WIFI_ON_GOT_IP){
|
||||
at.oob(FOTA_OOB_PREFIX, FOTA_OOB_POSTFIX, 64, fota_event_handler, NULL);
|
||||
aos_cli_register_commands(&module_ota_cli_cmd[0],sizeof(module_ota_cli_cmd) / sizeof(struct cli_command));
|
||||
LOG("Hello, WiFi GOT_IP event! at %s %d\r\n", __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int board_cli_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = aos_sem_new(&fota_status.stmoduelfotasem, 0);
|
||||
if (ret){
|
||||
printf("fail to creat sem4 %s %d \r\n", __FILE__, __LINE__);
|
||||
}
|
||||
fota_status.ret = 0;
|
||||
|
||||
aos_register_event_filter(EV_WIFI, wifi_event_handler, NULL);
|
||||
}
|
||||
|
||||
|
||||
322
Living_SDK/board/starterkit/st7789.c
Normal file
322
Living_SDK/board/starterkit/st7789.c
Normal file
|
|
@ -0,0 +1,322 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "stm32l4xx_hal.h"
|
||||
#include "soc_init.h"
|
||||
#include "st7789.h"
|
||||
|
||||
extern SPI_HandleTypeDef hspi1;
|
||||
static SPI_HandleTypeDef *hspi_lcd = NULL;
|
||||
|
||||
static struct st7789_function st7789_cfg_script[] = {
|
||||
{ST7789_START, ST7789_START},
|
||||
{ST7789_CMD, 0x11},
|
||||
{ST7789_DELAY, 120},
|
||||
{ST7789_CMD, 0x36},
|
||||
{ST7789_DATA, 0x00},
|
||||
{ST7789_CMD, 0x3a},
|
||||
{ST7789_DATA, 0x05},
|
||||
{ST7789_CMD, 0xb2},
|
||||
{ST7789_DATA, 0x0c},
|
||||
{ST7789_DATA, 0x0c},
|
||||
{ST7789_DATA, 0x00},
|
||||
{ST7789_DATA, 0x33},
|
||||
{ST7789_DATA, 0x33},
|
||||
{ST7789_CMD, 0xb7},
|
||||
{ST7789_DATA, 0x72},
|
||||
{ST7789_CMD, 0xbb},
|
||||
{ST7789_DATA, 0x3d},
|
||||
{ST7789_CMD, 0xc2},
|
||||
{ST7789_DATA, 0x01},
|
||||
{ST7789_CMD, 0xc3},
|
||||
{ST7789_DATA, 0x19},
|
||||
{ST7789_CMD, 0xc4},
|
||||
{ST7789_DATA, 0x20},
|
||||
{ST7789_CMD, 0xc6},
|
||||
{ST7789_DATA, 0x0f},
|
||||
{ST7789_CMD, 0xd0},
|
||||
{ST7789_DATA, 0xa4},
|
||||
{ST7789_DATA, 0xa1},
|
||||
{ST7789_CMD, 0xe0},
|
||||
{ST7789_DATA, 0x70},
|
||||
{ST7789_DATA, 0x04},
|
||||
{ST7789_DATA, 0x08},
|
||||
{ST7789_DATA, 0x09},
|
||||
{ST7789_DATA, 0x09},
|
||||
{ST7789_DATA, 0x05},
|
||||
{ST7789_DATA, 0x2a},
|
||||
{ST7789_DATA, 0x33},
|
||||
{ST7789_DATA, 0x41},
|
||||
{ST7789_DATA, 0x07},
|
||||
{ST7789_DATA, 0x13},
|
||||
{ST7789_DATA, 0x13},
|
||||
{ST7789_DATA, 0x29},
|
||||
{ST7789_DATA, 0x2f},
|
||||
{ST7789_CMD, 0xe1},
|
||||
{ST7789_DATA, 0x70},
|
||||
{ST7789_DATA, 0x03},
|
||||
{ST7789_DATA, 0x09},
|
||||
{ST7789_DATA, 0x0a},
|
||||
{ST7789_DATA, 0x09},
|
||||
{ST7789_DATA, 0x06},
|
||||
{ST7789_DATA, 0x2b},
|
||||
{ST7789_DATA, 0x34},
|
||||
{ST7789_DATA, 0x41},
|
||||
{ST7789_DATA, 0x07},
|
||||
{ST7789_DATA, 0x12},
|
||||
{ST7789_DATA, 0x14},
|
||||
{ST7789_DATA, 0x28},
|
||||
{ST7789_DATA, 0x2e},
|
||||
{ST7789_CMD, 0x21},
|
||||
{ST7789_CMD, 0x29},
|
||||
{ST7789_CMD, 0x2a},
|
||||
{ST7789_DATA, 0x00},
|
||||
{ST7789_DATA, 0x00},
|
||||
{ST7789_DATA, 0x00},
|
||||
{ST7789_DATA, 0xef},
|
||||
{ST7789_CMD, 0x2b},
|
||||
{ST7789_DATA, 0x00},
|
||||
{ST7789_DATA, 0x00},
|
||||
{ST7789_DATA, 0x00},
|
||||
{ST7789_DATA, 0xef},
|
||||
{ST7789_CMD, 0x2c},
|
||||
{ST7789_END, ST7789_END},
|
||||
};
|
||||
|
||||
static HAL_StatusTypeDef st7789_write(int is_cmd, uint8_t data)
|
||||
{
|
||||
uint8_t pData[2] = {0};
|
||||
|
||||
if (hspi_lcd == NULL) {
|
||||
_Error_Handler(__FILE__, __LINE__);
|
||||
return HAL_ERROR;
|
||||
}
|
||||
pData[0] = data;
|
||||
|
||||
#ifdef ALIOS_HAL
|
||||
if (is_cmd)
|
||||
hal_gpio_output_low(&brd_gpio_table[GPIO_LCD_DCX]);
|
||||
else
|
||||
hal_gpio_output_high(&brd_gpio_table[GPIO_LCD_DCX]);
|
||||
#else
|
||||
if (is_cmd)
|
||||
HAL_GPIO_WritePin(LCD_DCX_GPIO_Port, LCD_DCX_Pin, GPIO_PIN_RESET);
|
||||
else
|
||||
HAL_GPIO_WritePin(LCD_DCX_GPIO_Port, LCD_DCX_Pin, GPIO_PIN_SET);
|
||||
#endif
|
||||
|
||||
return HAL_SPI_Transmit(hspi_lcd, pData, 1, HAL_MAX_DELAY);
|
||||
}
|
||||
|
||||
static HAL_StatusTypeDef st7789_write_fb(uint16_t *data, uint16_t size)
|
||||
{
|
||||
if (hspi_lcd == NULL) {
|
||||
_Error_Handler(__FILE__, __LINE__);
|
||||
return HAL_ERROR;
|
||||
}
|
||||
|
||||
return HAL_SPI_Transmit(hspi_lcd, (uint8_t *)data, size, HAL_MAX_DELAY);
|
||||
}
|
||||
|
||||
static void st7789_run_cfg_script()
|
||||
{
|
||||
uint8_t data[2] = {0};
|
||||
int i = 0;
|
||||
int end_script = 0;
|
||||
|
||||
do {
|
||||
switch (st7789_cfg_script[i].cmd) {
|
||||
case ST7789_START:
|
||||
break;
|
||||
case ST7789_CMD:
|
||||
data[0] = st7789_cfg_script[i].data & 0xff;
|
||||
st7789_write(1, data[0]);
|
||||
break;
|
||||
case ST7789_DATA:
|
||||
data[0] = st7789_cfg_script[i].data & 0xff;
|
||||
st7789_write(0, data[0]);
|
||||
break;
|
||||
case ST7789_DELAY:
|
||||
krhino_task_sleep(krhino_ms_to_ticks(st7789_cfg_script[i].data));
|
||||
break;
|
||||
case ST7789_END:
|
||||
end_script = 1;
|
||||
}
|
||||
i++;
|
||||
} while (!end_script);
|
||||
}
|
||||
|
||||
static void st7789_reset()
|
||||
{
|
||||
#ifdef ALIOS_HAL
|
||||
hal_gpio_output_high(&brd_gpio_table[GPIO_LCD_PWR]);
|
||||
hal_gpio_output_high(&brd_gpio_table[GPIO_LCD_RST]);
|
||||
krhino_task_sleep(krhino_ms_to_ticks(50));
|
||||
hal_gpio_output_low(&brd_gpio_table[GPIO_LCD_RST]);
|
||||
krhino_task_sleep(krhino_ms_to_ticks(50));
|
||||
hal_gpio_output_high(&brd_gpio_table[GPIO_LCD_RST]);
|
||||
krhino_task_sleep(krhino_ms_to_ticks(150));
|
||||
#else
|
||||
HAL_GPIO_WritePin(LCD_PWR_GPIO_Port, LCD_PWR_Pin, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(LCD_RST_GPIO_Port, LCD_RST_Pin, GPIO_PIN_SET);
|
||||
HAL_Delay(50);
|
||||
/* Reset controller */
|
||||
HAL_GPIO_WritePin(LCD_RST_GPIO_Port, LCD_RST_Pin, GPIO_PIN_RESET);
|
||||
HAL_Delay(50);
|
||||
HAL_GPIO_WritePin(LCD_RST_GPIO_Port, LCD_RST_Pin, GPIO_PIN_SET);
|
||||
HAL_Delay(150);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void st7789_set_addr_win(uint16_t xs, uint16_t ys, uint16_t xe, uint16_t ye)
|
||||
{
|
||||
uint8_t col_data[4] = {0};
|
||||
uint8_t row_data[4] = {0};
|
||||
|
||||
col_data[0] = xs >> 8 & 0xff;
|
||||
col_data[1] = xs & 0xff;
|
||||
col_data[2] = xe >> 8 & 0xff;
|
||||
col_data[3] = xe & 0xff;
|
||||
row_data[0] = ys >> 8 & 0xff;
|
||||
row_data[1] = ys & 0xff;
|
||||
row_data[2] = ye >> 8 & 0xff;
|
||||
row_data[3] = ye & 0xff;
|
||||
st7789_write(1, ST7789_CASET);
|
||||
st7789_write(0, col_data[0]);
|
||||
st7789_write(0, col_data[1]);
|
||||
st7789_write(0, col_data[2]);
|
||||
st7789_write(0, col_data[3]);
|
||||
st7789_write(1, ST7789_RASET);
|
||||
st7789_write(0, row_data[0]);
|
||||
st7789_write(0, row_data[1]);
|
||||
st7789_write(0, row_data[2]);
|
||||
st7789_write(0, row_data[3]);
|
||||
}
|
||||
|
||||
#define LCD_MAX_MEM16_BLOCK (1 << 6)
|
||||
#define LCD_PIXEL_PER_BLOCK (LCD_MAX_MEM16_BLOCK >> 1)
|
||||
|
||||
static void spec_send_fb(uint16_t color, uint16_t pixel_num)
|
||||
{
|
||||
int i;
|
||||
int count, remain;
|
||||
uint16_t real_mem[LCD_MAX_MEM16_BLOCK] = {0};
|
||||
|
||||
for (i = 0; i < LCD_MAX_MEM16_BLOCK; ++i) {
|
||||
real_mem[i] = color;
|
||||
}
|
||||
HAL_GPIO_WritePin(LCD_DCX_GPIO_Port, LCD_DCX_Pin, GPIO_PIN_SET);
|
||||
if (pixel_num <= LCD_MAX_MEM16_BLOCK) {
|
||||
st7789_write_fb(real_mem, pixel_num << 1);
|
||||
} else {
|
||||
count = pixel_num / LCD_MAX_MEM16_BLOCK;
|
||||
remain = pixel_num % LCD_MAX_MEM16_BLOCK;
|
||||
for (i = 0; i < count; ++i) {
|
||||
st7789_write_fb(real_mem, LCD_MAX_MEM16_BLOCK << 1);
|
||||
}
|
||||
st7789_write_fb(real_mem, remain << 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void st7789_display_picture(void)
|
||||
{
|
||||
st7789_write(1, ST7789_RAMWR);
|
||||
|
||||
spec_send_fb(0x0, WIDTH * HEIGHT / 4);
|
||||
spec_send_fb(0x1111, WIDTH * HEIGHT / 4);
|
||||
spec_send_fb(0x7777, WIDTH * HEIGHT / 4);
|
||||
spec_send_fb(0xeeee, WIDTH * HEIGHT / 4);
|
||||
}
|
||||
#endif
|
||||
|
||||
int st7789_init()
|
||||
{
|
||||
hspi_lcd = &hspi1;
|
||||
st7789_reset();
|
||||
st7789_run_cfg_script();
|
||||
// st7789_display_picture();
|
||||
|
||||
return HAL_OK;
|
||||
}
|
||||
|
||||
void ST7789H2_WriteReg(uint8_t Command, uint8_t *Parameters, uint8_t NbParameters)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
/* Send command */
|
||||
LcdWriteReg(Command);
|
||||
|
||||
/* Send command's parameters if any */
|
||||
for (i=0; i<NbParameters; i++)
|
||||
{
|
||||
LcdWriteData(Parameters[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void ST7789H2_SetCursor(uint16_t Xpos, uint16_t Ypos)
|
||||
{
|
||||
uint8_t parameter[4];
|
||||
/* CASET: Comumn Addrses Set */
|
||||
parameter[0] = 0x00;
|
||||
parameter[1] = 0x00 + Xpos;
|
||||
parameter[2] = 0x00;
|
||||
parameter[3] = 0xEF + Xpos;
|
||||
ST7789H2_WriteReg(0x2A, parameter, 4);
|
||||
/* RASET: Row Addrses Set */
|
||||
parameter[0] = 0x00;
|
||||
parameter[1] = 0x00 + Ypos;
|
||||
parameter[2] = 0x00;
|
||||
parameter[3] = 0xEF + Ypos;
|
||||
ST7789H2_WriteReg(0x2B, parameter, 4);
|
||||
}
|
||||
|
||||
uint8_t black_gui[480] = {0};
|
||||
|
||||
void BSP_LCD_Clear(uint16_t Color)
|
||||
{
|
||||
uint32_t counter = 0;
|
||||
uint32_t y_size = 0;
|
||||
|
||||
memset(black_gui, 0xFF, sizeof(black_gui));
|
||||
|
||||
for (counter = 0; counter < 240; counter++)
|
||||
{
|
||||
/* Set Cursor */
|
||||
ST7789H2_SetCursor(0, counter);
|
||||
|
||||
/* Prepare to write to LCD RAM */
|
||||
ST7789H2_WriteReg(0x2C, (uint8_t*)NULL, 0); /* RAM write data command */
|
||||
|
||||
LcdWriteDataMultiple(black_gui, 480);
|
||||
}
|
||||
}
|
||||
|
||||
void ST7789H2_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode)
|
||||
{
|
||||
/* Set Cursor */
|
||||
ST7789H2_SetCursor(Xpos, Ypos);
|
||||
|
||||
/* Prepare to write to LCD RAM */
|
||||
ST7789H2_WriteReg(0x2C, (uint8_t*)NULL, 0); /* RAM write data command */
|
||||
|
||||
/* Write RAM data */
|
||||
LcdWriteDataMultiple(&RGBCode, 2);
|
||||
}
|
||||
|
||||
void LcdWriteReg(uint8_t Data)
|
||||
{
|
||||
HAL_GPIO_WritePin(LCD_DCX_GPIO_Port, LCD_DCX_Pin, GPIO_PIN_RESET);
|
||||
HAL_SPI_Transmit(&hspi1, &Data, 1, 10);
|
||||
}
|
||||
|
||||
void LcdWriteData(uint8_t Data)
|
||||
{
|
||||
HAL_GPIO_WritePin(LCD_DCX_GPIO_Port, LCD_DCX_Pin, GPIO_PIN_SET);
|
||||
HAL_SPI_Transmit(&hspi1, &Data, 1, 10);
|
||||
}
|
||||
|
||||
void LcdWriteDataMultiple(uint8_t * pData, int NumItems)
|
||||
{
|
||||
HAL_GPIO_WritePin(LCD_DCX_GPIO_Port, LCD_DCX_Pin, GPIO_PIN_SET);
|
||||
HAL_SPI_Transmit(&hspi1, pData, NumItems, 10);
|
||||
}
|
||||
34
Living_SDK/board/starterkit/st7789.h
Normal file
34
Living_SDK/board/starterkit/st7789.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef __ST7789_H
|
||||
#define __ST7789_H
|
||||
|
||||
#define WIDTH 240
|
||||
#define HEIGHT 240
|
||||
#define BPP 16
|
||||
|
||||
/* Init script function */
|
||||
struct st7789_function {
|
||||
uint8_t cmd;
|
||||
uint16_t data;
|
||||
};
|
||||
|
||||
/* Init script commands */
|
||||
enum st7789_cmd {
|
||||
ST7789_START,
|
||||
ST7789_END,
|
||||
ST7789_CMD,
|
||||
ST7789_DATA,
|
||||
ST7789_DELAY
|
||||
};
|
||||
|
||||
/* ST7789 Commands */
|
||||
#define ST7789_CASET 0x2A
|
||||
#define ST7789_RASET 0x2B
|
||||
#define ST7789_RAMWR 0x2C
|
||||
#define ST7789_RAMRD 0x2E
|
||||
|
||||
int st7789_init();
|
||||
void LcdWriteReg(uint8_t Data);
|
||||
void LcdWriteData(uint8_t Data);
|
||||
void LcdWriteDataMultiple(uint8_t * pData, int NumItems);
|
||||
|
||||
#endif /* __ST7789_H */
|
||||
38
Living_SDK/board/starterkit/starterkit.mk
Normal file
38
Living_SDK/board/starterkit/starterkit.mk
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
NAME := starterkit
|
||||
|
||||
|
||||
$(NAME)_TYPE := kernel
|
||||
MODULE := 1062
|
||||
HOST_ARCH := Cortex-M4
|
||||
HOST_MCU_FAMILY := stm32l4xx
|
||||
SUPPORT_BINS := no
|
||||
HOST_MCU_NAME := STM32L433RC-Nucleo
|
||||
ENABLE_VFP := 1
|
||||
|
||||
$(NAME)_SOURCES += board.c board_cli.c st7789.c
|
||||
|
||||
GLOBAL_INCLUDES += .
|
||||
|
||||
GLOBAL_DEFINES += STDIO_UART=0
|
||||
GLOBAL_DEFINES += CONFIG_AOS_CLI_BOARD
|
||||
|
||||
$(NAME)_COMPONENTS += sensor
|
||||
GLOBAL_DEFINES += AOS_SENSOR_ACC_MIR3_DA217
|
||||
GLOBAL_DEFINES += AOS_SENSOR_ALS_LITEON_LTR553
|
||||
GLOBAL_DEFINES += AOS_SENSOR_PS_LITEON_LTR553
|
||||
|
||||
sal ?= 1
|
||||
no_tls ?= 1
|
||||
ifeq (1,$(sal))
|
||||
$(NAME)_COMPONENTS += sal
|
||||
module ?= wifi.mk3060
|
||||
else
|
||||
GLOBAL_DEFINES += CONFIG_NO_TCPIP
|
||||
endif
|
||||
|
||||
CONFIG_SYSINFO_PRODUCT_MODEL := ALI_AOS_starterkit
|
||||
CONFIG_SYSINFO_DEVICE_NAME := starterkit
|
||||
|
||||
GLOBAL_CFLAGS += -DSYSINFO_OS_VERSION=\"$(CONFIG_SYSINFO_OS_VERSION)\"
|
||||
GLOBAL_CFLAGS += -DSYSINFO_PRODUCT_MODEL=\"$(CONFIG_SYSINFO_PRODUCT_MODEL)\"
|
||||
GLOBAL_CFLAGS += -DSYSINFO_DEVICE_NAME=\"$(CONFIG_SYSINFO_DEVICE_NAME)\"
|
||||
Loading…
Add table
Add a link
Reference in a new issue