4 Commits

Author SHA1 Message Date
e0900f9b73 [Mod] CMT2310 初始化完成
1. 使用系统延时实现硬件抽象层us、ms延时;
2. 完成SPI初始化、收发实现;
2024-07-25 20:35:55 +08:00
bb7b6e452b [Fix] 解决启动崩溃问题
Timer时钟使能,入参错误导致地址访问的硬件错误
2024-07-25 18:55:45 +08:00
f135363861 [Mod] 禁用led_task, 与CMT2310 冲突 2024-07-25 18:22:39 +08:00
48bc218fb1 [Mod] CMT2310 GPIO SPI初始化 2024-07-25 18:21:42 +08:00
12 changed files with 184 additions and 147 deletions

View File

@ -1,34 +1,34 @@
/*!
\file main.c
\brief TIMER2 oc timebase demo for gd32w51x
\version 2021-10-30, V1.0.0, firmware for GD32W51x
*/
/*
Copyright (c) 2021, GigaDevice Semiconductor Inc.
Redistribution and use in source and binary forms, with or without modification,
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
*/
@ -61,7 +61,7 @@ void nvic_config(void)
void timer_config(void)
{
/* ----------------------------------------------------------------------------
TIMER2 Configuration:
TIMER2 Configuration:
TIMER2CLK = SystemCoreClock/9000 = 20KHz.
TIMER2 configuration is timing mode, and the timing is 0.2s(4000/20000 = 0.2s).
---------------------------------------------------------------------------- */

View File

@ -114,6 +114,8 @@ OF SUCH DAMAGE.
#define ALICLOUD_TASK_PRIO TASK_PRIO_APP_BASE
#endif
//#define CONFIG_TASK_LED
#ifdef CONFIG_IPERF_TEST
#define IPERF_TASK_MAX 1

View File

@ -82,7 +82,7 @@ void do_ram_code_copy(void)
}
#endif
#if defined (CONFIG_GY3513)
#if defined (CONFIG_TASK_LED)
static int32_t led_init(void)
{
gd_eval_led_init(LED1);
@ -104,7 +104,7 @@ void led_task(void *p_arg)
sys_task_delete(NULL);
}
#endif // CONFIG_GY3513
#endif // CONFIG_TASK_LED
/*!
\brief initialize application
@ -168,14 +168,14 @@ void start_task(void *p_arg)
*/
int main(void)
{
#if defined (CONFIG_GY3513)
#if defined (CONFIG_TASK_LED)
TaskHandle_t *stTaskHndl_led = NULL;
#endif // CONFIG_GY3513
#endif // CONFIG_TASK_LED
platform_init();
#if defined (CONFIG_GY3513)
#if defined (CONFIG_TASK_LED)
led_init();
#endif // CONFIG_GY3513
#endif // CONFIG_TASK_LED
DEBUGPRINT("SDK git revision: "WIFI_GIT_REVISION" \r\n");
DEBUGPRINT("SDK version: V%d.%d.%d\r\n", (RE_NSPE_VERSION >> 24), ((RE_NSPE_VERSION & 0xFF0000) >> 16), (RE_NSPE_VERSION & 0xFFFF));
@ -187,7 +187,7 @@ int main(void)
systick_delay_init();
#if defined (CONFIG_GY3513)
#if defined (CONFIG_TASK_LED)
#define LED_TASK_STK_SIZE 256
#define LED_TASK_PRIO (TASK_PRIO_APP_BASE + TASK_PRIO_HIGHER(1))
@ -195,7 +195,7 @@ int main(void)
if (stTaskHndl_led == NULL) {
DEBUG_ERROR("Error, task create failed.\r\n");
}
#endif // CONFIG_GY3513
#endif // CONFIG_TASK_LED
if (NULL == sys_task_create(NULL, (const uint8_t *)"sub1g_task", NULL, START_TASK_STK_SIZE, 0, START_TASK_PRIO, sub1g_task, NULL)) {
DEBUGPRINT("ERROR: create start task failed\r\n");

View File

@ -735,6 +735,5 @@ void platform_init(void)
gdm3210x_fpga_init();
#elif CONFIG_PLATFORM == PLATFORM_ASIC_32W51X
gd32w51x_asic_init();
#endif
}

View File

@ -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);
}

View File

@ -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 );

View File

@ -59,11 +59,11 @@ static BSP_BTN_EVENT_t BTN_Event;
int ebyte_main( void )
{
/* <20><><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD>Դ <20><>ʼ<EFBFBD><CABC> */
// Ebyte_BSP_Init();
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> */

View File

@ -22,6 +22,7 @@
#include "board.h"
#include "ebyte_port.h"
#include "ebyte_conf.h"
#include "gd32w51x_gpio.h"
#include "platform_def.h"
BSP_BTN_FIFO_t BSP_BTN_FIFO;
@ -45,11 +46,13 @@ void Ebyte_BSP_HSI_Init(void)
void Ebyte_BSP_E48xGPIO_Init(void)
{
// GPIO_Init( BSP_GPIO_PORT_E48_GP0, BSP_GPIO_PIN_E48_GP0, GPIO_Mode_In_PU_No_IT );
// GPIO_Init( BSP_GPIO_PORT_E48_NIRQ, BSP_GPIO_PIN_E48_NIRQ, GPIO_Mode_In_PU_No_IT );
// GPIO_Init( BSP_GPIO_PORT_E48_GP3, BSP_GPIO_PIN_E48_GP3, GPIO_Mode_In_PU_No_IT );
// GPIO_Init( BSP_GPIO_PORT_E48_GP4, BSP_GPIO_PIN_E48_GP4, GPIO_Mode_In_FL_No_IT );
// GPIO_Init( BSP_GPIO_PORT_E48_GP5, BSP_GPIO_PIN_E48_GP5, GPIO_Mode_In_PU_No_IT );
rcu_periph_clock_enable(BSP_GPIO_RCU_E48_GPIO);
gpio_mode_set( BSP_GPIO_PORT_E48_GP0, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, BSP_GPIO_PIN_E48_GP0);
gpio_mode_set( BSP_GPIO_PORT_E48_NIRQ, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, BSP_GPIO_PIN_E48_NIRQ);
gpio_mode_set( BSP_GPIO_PORT_E48_GP3, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, BSP_GPIO_PIN_E48_GP3);
gpio_mode_set( BSP_GPIO_PORT_E48_GP4, GPIO_MODE_INPUT, GPIO_PUPD_NONE, BSP_GPIO_PIN_E48_GP4);
gpio_mode_set( BSP_GPIO_PORT_E48_GP5, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, BSP_GPIO_PIN_E48_GP5);
}
/* !
* @brief <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO
@ -58,15 +61,19 @@ void Ebyte_BSP_E48xGPIO_Init(void)
*/
void Ebyte_BSP_GPIO_Init(void)
{
// /* <20><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>״̬<D7B4><CCAC><EFBFBD><EFBFBD> */
// Ebyte_BSP_E48xGPIO_Init();
// /* LED */
// GPIO_Init( BSP_GPIO_PORT_LED_1, BSP_GPIO_PIN_LED_1, GPIO_Mode_Out_PP_Low_Slow );
// GPIO_Init( BSP_GPIO_PORT_LED_2, BSP_GPIO_PIN_LED_2, GPIO_Mode_Out_PP_Low_Slow );
//
// /* <20><><EFBFBD><EFBFBD> */
// GPIO_Init( BSP_GPIO_PORT_BUTTON_1, BSP_GPIO_PIN_BUTTON_1, GPIO_Mode_In_PU_No_IT );
//
/* <20><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>״̬<D7B4><CCAC><EFBFBD><EFBFBD> */
Ebyte_BSP_E48xGPIO_Init();
/* LED */
rcu_periph_clock_enable(BSP_GPIO_RCU_E48_LED);
gpio_mode_set( BSP_GPIO_PORT_LED_1, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, BSP_GPIO_PIN_LED_1 );
gpio_mode_set( BSP_GPIO_PORT_LED_2, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, BSP_GPIO_PIN_LED_2 );
gpio_output_options_set(BSP_GPIO_PORT_LED_1, GPIO_OTYPE_PP, GPIO_OSPEED_25MHZ, BSP_GPIO_PIN_LED_1);
gpio_output_options_set(BSP_GPIO_PORT_LED_2, GPIO_OTYPE_PP, GPIO_OSPEED_25MHZ, BSP_GPIO_PIN_LED_2);
/* Button */
rcu_periph_clock_enable(BSP_GPIO_RCU_E48_BUTTON);
gpio_mode_set( BSP_GPIO_PORT_BUTTON_1, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, BSP_GPIO_PIN_BUTTON_1);
// GPIO_Init( BSP_GPIO_PORT_BUTTON_2, BSP_GPIO_PIN_BUTTON_2, GPIO_Mode_In_PU_No_IT );
}
@ -107,26 +114,36 @@ void Ebyte_BSP_ThreeLinesSPI_Init()
*/
void Ebyte_BSP_SPI_Init( void )
{
// /* ʱ<><CAB1> */
// CLK_PeripheralClockConfig( CLK_Peripheral_SPI1, ENABLE);
//
// /* GPIO */
// GPIO_Init( BSP_GPIO_PORT_SPI_NSS, BSP_GPIO_PIN_SPI_NSS, GPIO_Mode_Out_PP_High_Slow); //Ƭѡ CS
spi_parameter_struct spi_init_struct;
/* ʱ<><CAB1> */
rcu_periph_clock_enable(BSP_RF_SPI_CLOCK);
rcu_periph_clock_enable(BSP_GPIO_RCU_E48_SPI);
/* 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> */
// SPI_Init( BSP_RF_SPI,
// SPI_FirstBit_MSB, //<2F>Ӹ<EFBFBD>λ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// SPI_BaudRatePrescaler_8, //16M/2 SCK<43><4B><EFBFBD><EFBFBD>
// SPI_Mode_Master, //<2F><><EFBFBD><EFBFBD>ģʽ
// SPI_CPOL_Low, //<2F><><EFBFBD><EFBFBD> CPOL=0
// SPI_CPHA_1Edge, //<EFBFBD><EFBFBD><EFBFBD><EFBFBD> CPHA=0 <20><>һ<EFBFBD><D2BB>ʱ<EFBFBD>ӱ<EFBFBD><D3B1>ز<EFBFBD><D8B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// SPI_Direction_2Lines_FullDuplex, //ȫ˫<EFBFBD><EFBFBD>
// SPI_NSS_Soft, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƴӻ<C6B4>CSƬѡ
// 0x07); //CRC<52><43><EFBFBD><EFBFBD>
//
// /* ʹ<EFBFBD><EFBFBD> */
// SPI_Cmd( BSP_RF_SPI, ENABLE );
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
spi_init_struct.trans_mode = SPI_TRANSMODE_FULLDUPLEX;
spi_init_struct.device_mode = SPI_MASTER; //<2F><><EFBFBD><EFBFBD>ģʽ
spi_init_struct.frame_size = SPI_FRAMESIZE_8BIT;
spi_init_struct.clock_polarity_phase = SPI_CK_PL_LOW_PH_1EDGE; // Mode0 {CPOL=0, CPHA=0}
spi_init_struct.nss = SPI_NSS_SOFT; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƴӻ<EFBFBD>CSƬѡ
spi_init_struct.prescale = SPI_PSC_8; //16M/2 SCK<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
spi_init_struct.endian = SPI_ENDIAN_MSB; //<EFBFBD>Ӹ<EFBFBD>λ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
spi_init(BSP_RF_SPI, &spi_init_struct);
/* ʹ<><CAB9> */
/* SPI enable */
spi_enable(BSP_RF_SPI);
}
/* !
@ -138,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);
//
@ -154,18 +177,35 @@ uint8_t Ebyte_BSP_SpiTransAndRecv( uint8_t data )
*/
void Ebyte_BSP_TIMER_Init( void )
{
// /* ʱ<><CAB1> */
// CLK_PeripheralClockConfig( CLK_Peripheral_TIM3, ENABLE);
//
// /* <20><><EFBFBD><EFBFBD> */
// TIM3_TimeBaseInit( TIM3_Prescaler_128 , TIM3_CounterMode_Up, 124);
//
// /* <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD> */
// TIM3_ClearFlag(TIM3_FLAG_Update);
// TIM3_ITConfig(TIM3_IT_Update, ENABLE);
//
// /* ʹ<><CAB9> */
// TIM3_Cmd(ENABLE);
timer_parameter_struct timer_initpara;
/**
TIMER2 Configuration:
TIMER2CLK = SystemCoreClock/180 = 1MHz.
TIMER2 configuration is timing mode, and the timing is 1ms(1000/1 = 1ms).
*/
/* enable the peripherals clock */
rcu_timer_clock_prescaler_config(RCU_TIMER_PSC_MUL4);
rcu_periph_clock_enable(BSP_RF_TIMER_RCU);
/* deinit a TIMER */
timer_deinit(BSP_RF_TIMER);
/* initialize TIMER init parameter struct */
timer_struct_para_init(&timer_initpara);
/* TIMER2 configuration */
timer_initpara.prescaler = 179;
timer_initpara.alignedmode = TIMER_COUNTER_EDGE;
timer_initpara.counterdirection = TIMER_COUNTER_UP;
timer_initpara.period = 1000;
timer_initpara.clockdivision = TIMER_CKDIV_DIV1;
timer_init(BSP_RF_TIMER, &timer_initpara);
/* clear interrupt bit */
timer_interrupt_flag_clear(BSP_RF_TIMER, TIMER_INT_FLAG_UP);
/* enable the TIMER interrupt */
timer_interrupt_enable(BSP_RF_TIMER, TIMER_INT_UP);
/* enable a TIMER */
timer_enable(BSP_RF_TIMER);
}
/* !
@ -181,13 +221,13 @@ void Ebyte_BSP_TIMER_Init( void )
void Ebyte_BSP_Init( void )
{
/* ʱ<><CAB1> <20><>ʼ<EFBFBD><CABC> */
Ebyte_BSP_HSI_Init();
// Ebyte_BSP_HSI_Init();
/* IO <20><>ʼ<EFBFBD><CABC> */
Ebyte_BSP_GPIO_Init();
/* <20><><EFBFBD><EFBFBD> <20><>ʼ<EFBFBD><CABC> */
Ebyte_BSP_UART_Init();
// Ebyte_BSP_UART_Init();
/* SPI<50>ӿ<EFBFBD> <20><>ʼ<EFBFBD><CABC> */
Ebyte_BSP_SPI_Init();
@ -276,8 +316,8 @@ uint8_t Ebyte_BSP_ReadButton( BSP_BUTTON_t btn )
switch ( btn )
{
case BSP_BUTTON_1: result = GPIO_ReadInputDataBit( BSP_GPIO_PORT_BUTTON_1 , BSP_GPIO_PIN_BUTTON_1); break;
case BSP_BUTTON_2: result = GPIO_ReadInputDataBit( BSP_GPIO_PORT_BUTTON_2 , BSP_GPIO_PIN_BUTTON_2); break;
case BSP_BUTTON_1: result = gpio_input_bit_get( BSP_GPIO_PORT_BUTTON_1 , BSP_GPIO_PIN_BUTTON_1); break;
// case BSP_BUTTON_2: result = GPIO_ReadInputDataBit( BSP_GPIO_PORT_BUTTON_2 , BSP_GPIO_PIN_BUTTON_2); break;
default : break;
}

View File

@ -28,31 +28,29 @@
#include "board_mini_printf.h"
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> LED */
#define BSP_GPIO_PORT_LED_1 GPIOC
#define BSP_GPIO_RCU_E48_LED RCU_GPIOB
#define BSP_GPIO_PORT_LED_1 GPIOB
#define BSP_GPIO_PIN_LED_1 GPIO_PIN_6
#define BSP_GPIO_PORT_LED_2 GPIOC
#define BSP_GPIO_PIN_LED_2 GPIO_PIN_5
#define BSP_GPIO_PORT_LED_2 GPIOA
#define BSP_GPIO_PIN_LED_2 GPIO_PIN_15
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> */
#define BSP_GPIO_RCU_E48_BUTTON RCU_GPIOA
#define BSP_GPIO_PORT_BUTTON_1 GPIOA
#define BSP_GPIO_PIN_BUTTON_1 GPIO_PIN_4
#define BSP_GPIO_PIN_BUTTON_1 GPIO_PIN_2
#define BSP_GPIO_PORT_BUTTON_2 GPIOA
#define BSP_GPIO_PIN_BUTTON_2 GPIO_PIN_5
//#define BSP_GPIO_PORT_BUTTON_2 GPIOA
//#define BSP_GPIO_PIN_BUTTON_2 GPIO_PIN_5
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> SPIͨ<49>Žӿ<C5BD> */
#define BSP_GPIO_PORT_SPI_NSS GPIOB
#define BSP_GPIO_PIN_SPI_NSS GPIO_PIN_4
#define BSP_GPIO_RCU_E48_SPI RCU_GPIOB
#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_PORT_SPI GPIOB
#define BSP_GPIO_PIN_SPI_NSS GPIO_PIN_12
#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
@ -65,24 +63,28 @@
/* E48 */
#define BSP_GPIO_RCU_E48_GPIO RCU_GPIOC
#define BSP_GPIO_PORT_E48_GP0 GPIOC
#define BSP_GPIO_PIN_E48_GP0 GPIO_PIN_1
#define BSP_GPIO_PORT_E48_NIRQ GPIOD
#define BSP_GPIO_PIN_E48_NIRQ GPIO_PIN_4
#define BSP_GPIO_PIN_E48_GP0 GPIO_PIN_0
#define BSP_GPIO_PORT_E48_NIRQ GPIOC
#define BSP_GPIO_PIN_E48_NIRQ GPIO_PIN_1
#define BSP_GPIO_PORT_E48_GP3 GPIOC
#define BSP_GPIO_PIN_E48_GP3 GPIO_PIN_3
#define BSP_GPIO_PORT_E48_GP4 GPIOC
#define BSP_GPIO_PIN_E48_GP4 GPIO_PIN_1
#define BSP_GPIO_PIN_E48_GP4 GPIO_PIN_4
#define BSP_GPIO_PORT_E48_GP5 GPIOC
#define BSP_GPIO_PIN_E48_GP5 GPIO_PIN_2
#define BSP_GPIO_PIN_E48_GP5 GPIO_PIN_5
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> SPI */
#define BSP_RF_SPI SPI1
#define BSP_RF_SPI_CLOCK CLK_Peripheral_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 BSP_RF_SPI_CLOCK RCU_SPI1
#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
#define BSP_RF_TIMER_RCU RCU_TIMER2
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IO */

View File

@ -1,19 +1,19 @@
/**
**********************************************************************************
* @file board_button.c
* @brief ͨ<><CDA8> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @author JiangHeng
* @date 2021-05-06
* @version 1.0.0
* @brief ͨ<><CDA8> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @author JiangHeng
* @date 2021-05-06
* @version 1.0.0
**********************************************************************************
* @copyright BSD License
* <20>ɶ<EFBFBD><C9B6>ڰ<EFBFBD><DAB0>ص<EFBFBD><D8B5>ӿƼ<D3BF><C6BC><EFBFBD><EFBFBD>޹<EFBFBD>˾
* ______ ____ __ __ _______ ______
* @copyright BSD License
* <20>ɶ<EFBFBD><C9B6>ڰ<EFBFBD><DAB0>ص<EFBFBD><D8B5>ӿƼ<D3BF><C6BC><EFBFBD><EFBFBD>޹<EFBFBD>˾
* ______ ____ __ __ _______ ______
* | ____| | _ \ \ \ / / |__ __| | ____|
* | |__ | |_) | \ \_/ / | | | |__
* | __| | _ < \ / | | | __|
* | |____ | |_) | | | | | | |____
* |______| |____/ |_| |_| |______|
* | |__ | |_) | \ \_/ / | | | |__
* | __| | _ < \ / | | | __|
* | |____ | |_) | | | | | | |____
* |______| |____/ |_| |_| |______|
*
**********************************************************************************
*/
@ -22,7 +22,7 @@
/* !
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD>ʼ<EFBFBD><CABC>
*
*
* @param fifo ָ<>򰴼<EFBFBD><F2B0B4BC>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>нṹ<D0BD><E1B9B9><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
*/
void Ebyte_BTN_FIFO_Init(BSP_BTN_FIFO_t *fifo)
@ -33,8 +33,8 @@ void Ebyte_BTN_FIFO_Init(BSP_BTN_FIFO_t *fifo)
}
/* !
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* @param fifo ָ<>򰴼<EFBFBD><F2B0B4BC>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>нṹ<D0BD><E1B9B9><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
* @param event <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD> <20><>ҪΪ<D2AA><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ̰<C4B6>/<2F><><EFBFBD><EFBFBD>
* @return 0:<3A><><EFBFBD><EFBFBD> 1:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@ -49,12 +49,12 @@ uint8_t Ebyte_BTN_FIFO_Push(BSP_BTN_FIFO_t *fifo, BSP_BTN_EVENT_t event)
if(fifo->fifoLen > BSP_BTN_FIFO_LENGTH)
{
fifo->fifoLen = BSP_BTN_FIFO_LENGTH;//<2F><><EFBFBD>ӳ<EFBFBD><D3B3>Ȳ<EFBFBD><C8B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
return 1;
return 1;
}
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
fifo->buff[fifo->fifoWrite] = event;
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>˶<EFBFBD>β */
if(++fifo->fifoWrite >= BSP_BTN_FIFO_LENGTH)
{
@ -67,7 +67,7 @@ uint8_t Ebyte_BTN_FIFO_Push(BSP_BTN_FIFO_t *fifo, BSP_BTN_EVENT_t event)
/* !
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><D0B3><EFBFBD>
*
*
* @param fifo ָ<>򰴼<EFBFBD><F2B0B4BC>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>нṹ<D0BD><E1B9B9><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
* @param event <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD> <20><>ҪΪ<D2AA><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ̰<C4B6>/<2F><><EFBFBD><EFBFBD>
* @return 0:<3A><><EFBFBD><EFBFBD> 1:<3A><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>
@ -79,7 +79,7 @@ uint8_t Ebyte_BTN_FIFO_Pop(BSP_BTN_FIFO_t *fifo, BSP_BTN_EVENT_t *event)
{
return 1;
}
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD><EFBFBD>Լ<EFBFBD> */
fifo->fifoLen--;

View File

@ -28,8 +28,8 @@ uint8_t radio_rece_data_flag;
void Ebyte_E48x_Init( void )
{
vRadioCheckLink();
vRadioInit();
vRadioCheckLink();
vRadioInit();
}
void Ebyte_E48x_SendPayload( uint8_t *payload, uint8_t size, uint32_t timeout )

View File

@ -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);
}
/******************************