[Mod] CMT2310 初始化完成
1. 使用系统延时实现硬件抽象层us、ms延时; 2. 完成SPI初始化、收发实现;
This commit is contained in:
@ -735,6 +735,5 @@ void platform_init(void)
|
||||
gdm3210x_fpga_init();
|
||||
#elif CONFIG_PLATFORM == PLATFORM_ASIC_32W51X
|
||||
gd32w51x_asic_init();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
|
||||
/*= !!!<21><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>Ӳ<EFBFBD><D3B2>ƽ̨ͷ<CCA8>ļ<EFBFBD> =======================================*/
|
||||
#include "board.h" //E15-EVB02 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#include "wrapper_os.h"
|
||||
/*==================================================================*/
|
||||
|
||||
/* !
|
||||
@ -77,22 +78,20 @@ void Ebyte_Port_SpiCsIoControl( uint8e_t cmd )
|
||||
void Ebyte_Port_DelayMs( uint16e_t time )
|
||||
{
|
||||
/* !<21><><EFBFBD><EFBFBD><EFBFBD>ṩ: <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> */
|
||||
|
||||
uint16e_t i,n;
|
||||
|
||||
while(time--)//<2F><><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>STM8L 16Mʱ<4D><CAB1>ǰ<EFBFBD><C7B0><EFBFBD>µĴ<C2B5><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
|
||||
{
|
||||
for(i=900;i>0;i--)
|
||||
{
|
||||
for( n=1 ;n>0 ;n--) {
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
__NOP();
|
||||
}
|
||||
}
|
||||
}
|
||||
sys_ms_sleep(time);
|
||||
}
|
||||
|
||||
|
||||
/* !
|
||||
* @brief <20><><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF>Ӳ<EFBFBD><D3B2>ƽ̨<C6BD><CCA8>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
*
|
||||
* @param time <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
* @note <20><>ע<EFBFBD><D7A2>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ô˺<C3B4><CBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD>Ӱ<EFBFBD>쵽<EFBFBD>˺<EFBFBD><CBBA><EFBFBD>
|
||||
*/
|
||||
void Ebyte_Port_DelayUs( uint16e_t time )
|
||||
{
|
||||
/* !<21><><EFBFBD><EFBFBD><EFBFBD>ṩ: <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD> */
|
||||
sys_us_delay(time);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ void Ebyte_Port_RstIoControl( uint8e_t cmd );
|
||||
void Ebyte_Port_TxenIoControl( uint8e_t cmd );
|
||||
void Ebyte_Port_RxenIoControl( uint8e_t cmd );
|
||||
void Ebyte_Port_DelayMs( uint16e_t time );
|
||||
void Ebyte_Port_DelayUs( uint16e_t time );
|
||||
void Ebyte_Port_SpiCsIoControl( uint8e_t cmd );
|
||||
|
||||
uint8e_t Ebyte_Port_BusyIoRead( void );
|
||||
|
||||
@ -61,9 +61,9 @@ int ebyte_main( void )
|
||||
/* <20><><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD>Դ <20><>ʼ<EFBFBD><CABC> */
|
||||
Ebyte_BSP_Init();
|
||||
/* (<28><>ѡ) <20><><EFBFBD><EFBFBD><EFBFBD>жϽ<D0B6><CFBD><EFBFBD>FIFO <20>ɸ<EFBFBD><C9B8><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>д<EFBFBD><D0B4><EFBFBD> */
|
||||
// Ebyte_FIFO_Init( &hfifo, EBYTE_FIFO_SIZE );
|
||||
Ebyte_FIFO_Init( &hfifo, EBYTE_FIFO_SIZE );
|
||||
/* EBYTE <20><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC> */
|
||||
// Ebyte_RF.Init();
|
||||
Ebyte_RF.Init();
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
// Ebyte_RF.EnterReceiveMode( 0 );
|
||||
/* MCU <20><>ȫ<EFBFBD><C8AB><EFBFBD>ж<EFBFBD> */
|
||||
|
||||
@ -118,11 +118,17 @@ void Ebyte_BSP_SPI_Init( void )
|
||||
|
||||
/* ʱ<><CAB1> */
|
||||
rcu_periph_clock_enable(BSP_RF_SPI_CLOCK);
|
||||
|
||||
/* GPIO */
|
||||
rcu_periph_clock_enable(BSP_GPIO_RCU_E48_SPI);
|
||||
gpio_mode_set(BSP_GPIO_PORT_SPI_NSS, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, BSP_GPIO_PIN_SPI_NSS); //Ƭѡ CS
|
||||
gpio_output_options_set(BSP_GPIO_PORT_SPI_NSS, GPIO_OTYPE_PP, GPIO_OSPEED_25MHZ, BSP_GPIO_PIN_SPI_NSS);
|
||||
|
||||
/* SPI1 GPIO config: SCK/PB13, MISO/PB14, MOSI/PB15 */
|
||||
gpio_af_set(BSP_GPIO_PORT_SPI, GPIO_AF_5, GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15);
|
||||
gpio_mode_set(BSP_GPIO_PORT_SPI, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15);
|
||||
gpio_output_options_set(BSP_GPIO_PORT_SPI, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15);
|
||||
|
||||
/* SPI0_NSS */
|
||||
gpio_mode_set(BSP_GPIO_PORT_SPI, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, BSP_GPIO_PIN_SPI_NSS); //Ƭѡ CS
|
||||
gpio_output_options_set(BSP_GPIO_PORT_SPI, GPIO_OTYPE_PP, GPIO_OSPEED_25MHZ, BSP_GPIO_PIN_SPI_NSS);
|
||||
|
||||
// GPIO_ExternalPullUpConfig( BSP_GPIO_PORT_SPI_SCK, BSP_GPIO_PIN_SPI_MOSI | BSP_GPIO_PIN_SPI_MISO | BSP_GPIO_PIN_SPI_SCK, ENABLE); // MOSI MISO SCK
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||
@ -149,6 +155,12 @@ void Ebyte_BSP_SPI_Init( void )
|
||||
*/
|
||||
uint8_t Ebyte_BSP_SpiTransAndRecv( uint8_t data )
|
||||
{
|
||||
while(RESET == spi_i2s_flag_get(BSP_RF_SPI, SPI_FLAG_TBE));
|
||||
spi_i2s_data_transmit(BSP_RF_SPI, data);
|
||||
|
||||
while(RESET == spi_i2s_flag_get(BSP_RF_SPI, SPI_FLAG_RBNE));
|
||||
return spi_i2s_data_receive(BSP_RF_SPI);
|
||||
|
||||
// BSP_RF_SPI->DR = data;
|
||||
// while ((BSP_RF_SPI->SR & SPI_FLAG_TXE) == RESET);
|
||||
//
|
||||
|
||||
@ -46,17 +46,11 @@
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> SPIͨ<49>Žӿ<C5BD> */
|
||||
#define BSP_GPIO_RCU_E48_SPI RCU_GPIOB
|
||||
|
||||
#define BSP_GPIO_PORT_SPI_NSS GPIOB
|
||||
#define BSP_GPIO_PORT_SPI GPIOB
|
||||
#define BSP_GPIO_PIN_SPI_NSS GPIO_PIN_12
|
||||
|
||||
//#define BSP_GPIO_PORT_SPI_MOSI GPIOB
|
||||
//#define BSP_GPIO_PIN_SPI_MOSI GPIO_PIN_6
|
||||
//
|
||||
//#define BSP_GPIO_PORT_SPI_MISO GPIOB
|
||||
//#define BSP_GPIO_PIN_SPI_MISO GPIO_PIN_7
|
||||
//
|
||||
//#define BSP_GPIO_PORT_SPI_SCK GPIOB
|
||||
//#define BSP_GPIO_PIN_SPI_SCK GPIO_PIN_5
|
||||
#define BSP_GPIO_PIN_SPI_SCK GPIO_PIN_13
|
||||
#define BSP_GPIO_PIN_SPI_MISO GPIO_PIN_14
|
||||
#define BSP_GPIO_PIN_SPI_MOSI GPIO_PIN_15
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ͨ<>Ŵ<EFBFBD><C5B4><EFBFBD> */
|
||||
#define BSP_GPIO_PORT_UART_TX GPIOA
|
||||
@ -85,8 +79,8 @@
|
||||
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> SPI */
|
||||
#define BSP_RF_SPI SPI1
|
||||
#define BSP_RF_SPI_CLOCK RCU_SPI1
|
||||
#define Ebyte_BSP_RfSpiSelected() gpio_bit_write( BSP_GPIO_PORT_SPI_NSS , BSP_GPIO_PIN_SPI_NSS, RESET )
|
||||
#define Ebyte_BSP_RfSpiUnselected() gpio_bit_write( BSP_GPIO_PORT_SPI_NSS , BSP_GPIO_PIN_SPI_NSS, SET )
|
||||
#define Ebyte_BSP_RfSpiSelected() gpio_bit_write( BSP_GPIO_PORT_SPI, BSP_GPIO_PIN_SPI_NSS, RESET )
|
||||
#define Ebyte_BSP_RfSpiUnselected() gpio_bit_write( BSP_GPIO_PORT_SPI, BSP_GPIO_PIN_SPI_NSS, SET )
|
||||
|
||||
/* <20><><EFBFBD><EFBFBD> Timer */
|
||||
#define BSP_RF_TIMER TIMER2
|
||||
|
||||
@ -7,13 +7,7 @@ void delay1ms(uint16_t cnt)
|
||||
|
||||
void delay10us(uint32_t cnt)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
while( cnt-- ) {
|
||||
i = 20;
|
||||
while(i--)
|
||||
__NOP();
|
||||
}
|
||||
Ebyte_Port_DelayUs(cnt * 10);
|
||||
}
|
||||
|
||||
/******************************
|
||||
|
||||
Reference in New Issue
Block a user