xr806 spi驱动出现问题
-
在做xr806的spi驱动的时候,只加了HAL_SPI_Deinit(DEMO_SPI_PORT);都会出错,代码如下:
static void MainThread(void *arg)
{HAL_SPI_Deinit(DEMO_SPI_PORT);
SPI_Global_Config spi_param;spi_param.cs_level = DEMO_SPI_CS_LEVEL;
spi_param.mclk = DEMO_SPI_MCLK;HAL_SPI_Init(DEMO_SPI_PORT, &spi_param);
while (1) {
IoTGpioSetOutputVal(GPIO_ID_PA21, 1);
OS_MSleep(500);
IoTGpioSetOutputVal(GPIO_ID_PA21, 0);
OS_MSleep(500);
}
}void LCDMain(void)
{
if (OS_ThreadCreate(&g_main_thread, "MainThread", MainThread, NULL,OS_THREAD_PRIO_APP, 4 * 1024) != OS_OK) {
printf("[ERR] Create MainThread Failed\n");
}
}
SYS_RUN(LCDMain);串口打印的log是如下内容
====================================================================
Hello! OpenHarmony!
System tag : OpenHarmony 1.1.2_LTSuse default flash chip mJedec 0x0
[FD I]: mode: 0x10, freq: 96000000Hz, drv: 0
[FD I]: jedec: 0x0, suspend_support: 1
mode select:ewlan information ===================================================
firmware:
version : R0-XR_C07.08.52.65_02.84 May 27 2021 11:41:33-Y02.84
buffer : 8
driver:
version : XR_V02.05
mac address:
in use : 4c:6e:c8:3e:c2:01
in use : 4c:6e:c8:3e:c2:02wlan mode:a
[VFS INF] SPIFFS mount success.platform information ===============================================
XR806 SDK v1.2.0 Jan 15 2022 15:52:31heap space [0x228900, 0x247c00), size 127744
cpu clock 160000000 Hz
HF clock 40000000 Hzsdk option:
XIP : enable
INT LF OSC : enable
SIP flash : enablemac address:
efuse : 80:74:84:05:ba:de
in use : 4c:6e:c8:3e:c2:01hiview init success.[SPI Alert] Changing State incorrectly in HAL_SPI_Deinit
console init success
-
@aktoey 去初始化函数,只有在初始化成功后才能使用
-
@i_a_student 我先试的init然后才试的deinit,都不行
-
@aktoey 试了一下,没啥问题,破案了,一定是你敲代码的姿势不对。
Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号