Compare commits
4 Commits
Develop_Ev
...
Develop_Ev
| Author | SHA1 | Date | |
|---|---|---|---|
| 518eb9f134 | |||
| de1285ff41 | |||
| b9f5afd78e | |||
| e7c70664d6 |
@ -149,6 +149,274 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#if ( PRODUCT_FREQUENCY == CM2310A_868MHZ)
|
||||
|
||||
const uint8_t g_cmt2310a_page0[CMT2310A_PAGE0_SIZE] = {
|
||||
0x2A,
|
||||
0x42,
|
||||
0x00,
|
||||
0xAA,
|
||||
0x04,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x64,
|
||||
0xD1,
|
||||
0xCE,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x64,
|
||||
0xD1,
|
||||
0xCE,
|
||||
0x1F,
|
||||
0x00,
|
||||
0x01,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x2D,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x2D,
|
||||
0x41,
|
||||
0x00,
|
||||
0x00,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0x00,
|
||||
0x00,
|
||||
0x05,
|
||||
0x80,
|
||||
0x00,
|
||||
0x00,
|
||||
0x08,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x1F,
|
||||
0x07,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0xE4,
|
||||
0x20,
|
||||
0x1A,
|
||||
0x60,
|
||||
0x08,
|
||||
0x00,
|
||||
0xAA,
|
||||
0x00,
|
||||
0xE2,
|
||||
0x82,
|
||||
0x38,
|
||||
0x00,
|
||||
0xD0,
|
||||
0xE0,
|
||||
0x80,
|
||||
0x00,
|
||||
0x41,
|
||||
0x00,
|
||||
0x01,
|
||||
0x00,
|
||||
0x02,
|
||||
0x00,
|
||||
0x00,
|
||||
0x03,
|
||||
0x04,
|
||||
};
|
||||
|
||||
const uint8_t g_cmt2310a_page1[CMT2310A_PAGE1_SIZE] = {
|
||||
0x10,
|
||||
0x06,
|
||||
0x00,
|
||||
0xFF,
|
||||
0x00,
|
||||
0xCD, // vRadioTcxoDrvSel 接收设置的,将0xcd变为了0x0d
|
||||
0x0E,
|
||||
0x20,
|
||||
0x50,
|
||||
0x87,
|
||||
0x31,
|
||||
0x5B,
|
||||
0x08,
|
||||
0x38,
|
||||
0xFF,
|
||||
0x00,
|
||||
0x6C,
|
||||
0x00,
|
||||
0x00,
|
||||
0x08,
|
||||
0xB4,
|
||||
0x04,
|
||||
0x56,
|
||||
0xE0,
|
||||
0x20,
|
||||
0x08,
|
||||
0x01,
|
||||
0x10,
|
||||
0x11,
|
||||
0x00,
|
||||
0x91,
|
||||
0x7F,
|
||||
0x00,
|
||||
0x18,
|
||||
0x00,
|
||||
0x00,
|
||||
0x1F,
|
||||
0xE4,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0xC0,
|
||||
0x6C,
|
||||
0x00,
|
||||
0x80,
|
||||
0x98,
|
||||
0x6B,
|
||||
0x00,
|
||||
0x80,
|
||||
0x0F,
|
||||
0x64,
|
||||
0x06,
|
||||
0x02,
|
||||
0x04,
|
||||
0x56,
|
||||
0x00,
|
||||
0x36,
|
||||
0x05,
|
||||
0x20,
|
||||
0xC8,
|
||||
0x63,
|
||||
0xA1,
|
||||
0xFA,
|
||||
0x02,
|
||||
0x58,
|
||||
0x40,
|
||||
0x54,
|
||||
0x74,
|
||||
0xD0,
|
||||
0x0F,
|
||||
0x01,
|
||||
0x1B,
|
||||
0xE6,
|
||||
0x54,
|
||||
0x0C,
|
||||
0x09,
|
||||
0xE2,
|
||||
0x33,
|
||||
0x04,
|
||||
0x01,
|
||||
0xA5,
|
||||
0x06,
|
||||
0x0F,
|
||||
0x12,
|
||||
0x4C,
|
||||
0x00,
|
||||
0x00,
|
||||
0xF6,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x18,
|
||||
0x81,
|
||||
0x00,
|
||||
0x00,
|
||||
0x47,
|
||||
0x12, //0x67寄存器,ANT_DIVERSITY_MODE设置电线分集的接口会修改它
|
||||
0x25,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
};
|
||||
|
||||
/* [CMT page2] */
|
||||
const uint8_t g_cmt2310a_page2[CMT2310A_PAGE2_SIZE] = {
|
||||
0x00,
|
||||
0x01,
|
||||
0x02,
|
||||
0x03,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
};
|
||||
|
||||
#if 0
|
||||
/* [CMT page0] */
|
||||
const uint8_t g_cmt2310a_page0[CMT2310A_PAGE0_SIZE] = {
|
||||
0x12,
|
||||
@ -350,3 +618,4 @@ const uint8_t g_cmt2310a_page1[CMT2310A_PAGE1_SIZE] = {
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -21,6 +21,8 @@
|
||||
|
||||
#include "board.h"
|
||||
|
||||
#define GET_CHIP_INFO_RETRY_MAX 10
|
||||
|
||||
uint8_t rf_rxbuffer[200];
|
||||
uint8_t rf_rxsize;
|
||||
uint8_t radio_rece_data_flag;
|
||||
@ -29,28 +31,50 @@ extern uint32_t g_chip_id;
|
||||
|
||||
void Ebyte_E48x_Init( void )
|
||||
{
|
||||
int ret;
|
||||
uint8_t chip_state = 0;
|
||||
uint32_t fail_retry = 0;
|
||||
boolean_t is_chip_cmt2310 = FALSE;
|
||||
|
||||
vSpiMasterInit();
|
||||
|
||||
init_prepare:
|
||||
/* Step1 */
|
||||
g_chip_id = lRadioChipVersion();
|
||||
chip_state = bRadioGetState();
|
||||
// OSAL_LOGD("Debug, got information Version[%#X] State[%#X].", g_chip_id, chip_state);
|
||||
|
||||
is_chip_cmt2310 = ((g_chip_id & 0x00FFFF00) == 0x00231000);
|
||||
if (is_chip_cmt2310 && (chip_state == CMT2310A_STATE_IS_READY)) {
|
||||
printf("Infor, CMT2310 already in State[READY], so skip initialization.");
|
||||
goto init_end;
|
||||
}
|
||||
else if (is_chip_cmt2310 && (!chip_state || chip_state & 0x80)) { // Valid mode, except IDLE and READY
|
||||
printf("Debug, initialize CMT2310 right now with current State[%#X].", chip_state);
|
||||
goto init_run;
|
||||
}
|
||||
else if (fail_retry++ >= GET_CHIP_INFO_RETRY_MAX) {
|
||||
printf("Error, get the information of CMT2310 failed with Chip-ID[%#X] State[%#X].", g_chip_id, chip_state);
|
||||
return -1;
|
||||
}
|
||||
else if (fail_retry == 1) {
|
||||
vRadioPowerUp(); // Release RST(GPIO5)
|
||||
vRadioSetAntSwitch(FALSE, FALSE); // Disable GPIO0 & GPIO1 as antenna switch control
|
||||
vRadioSpiModeSel(FALSE); // SPI 4-Wire mode
|
||||
delay1ms(20);
|
||||
}
|
||||
|
||||
/* Step2 */
|
||||
g_chip_id = lRadioChipVersion();
|
||||
if(0x00231000 != (g_chip_id & 0x00FFFF00)) {
|
||||
EBYTE_LOG("[%s|%u] Error, dismatch Chip-ID[%#x](!=0x231000).\r\n", __FUNCTION__, __LINE__, g_chip_id);
|
||||
return;
|
||||
}
|
||||
EBYTE_LOG("[%s|%u] Info, Link Device:E48-XXXM20S.\r\n", __FUNCTION__, __LINE__);
|
||||
vRadioSoftReset(); // Software reset
|
||||
vRadioBoot(); // Boot CMT2310 core
|
||||
delay1ms(50);
|
||||
|
||||
/* Step3 */
|
||||
if (bRadioGetState() == CMT2310A_STATE_IS_READY) {
|
||||
EBYTE_LOG("[%s|%u] Infor, CMT2310 already in State[READY], so skip initialization.\r\n", __FUNCTION__, __LINE__);
|
||||
return;
|
||||
}
|
||||
EBYTE_LOG("[%s|%u] Info, goto initialize E48-XXXM20S.\r\n", __FUNCTION__, __LINE__);
|
||||
|
||||
/* Step4 */
|
||||
goto init_prepare;
|
||||
init_run:
|
||||
/* Step3~6 */
|
||||
vRadioInit();
|
||||
|
||||
init_end:
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Ebyte_E48x_SendPayload( uint8_t *payload, uint8_t size, uint32_t timeout )
|
||||
|
||||
@ -430,6 +430,11 @@ void vRadioRegPageSel( uint8_t page_sel )
|
||||
}
|
||||
}
|
||||
|
||||
void vRadioBoot( void )
|
||||
{
|
||||
bSpiWriteByte( CMT2310A_CTL_REG_00, CMT2310A_REBOOT );
|
||||
}
|
||||
|
||||
/******************************
|
||||
**Name: vRadioPowerUpBoot
|
||||
**Func: Radio power up boot start
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
#define CM2310A_868MHZ 2
|
||||
#define CM2310A_915MHZ 3
|
||||
|
||||
#define PRODUCT_FREQUENCY CM2310A_410MHZ//ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>
|
||||
#define PRODUCT_FREQUENCY CM2310A_433MHZ//ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>
|
||||
|
||||
#include "radio_spi.h"
|
||||
#include "CMT2310A_def.h"
|
||||
@ -83,7 +83,6 @@ extern void vRadioXoWaitCfg( uint8_t div_sel );
|
||||
|
||||
extern void delay1ms(uint16_t cnt);
|
||||
extern void delay10us(uint32_t cnt);
|
||||
|
||||
void vRadioBoot( void );
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@ -76,6 +76,9 @@ static void jump_to_main_image(uint32_t msp, uint32_t reset)
|
||||
img_reset = (img_fptr_t)reset;
|
||||
|
||||
// __disable_irq();
|
||||
for (int i = 0; i < sizeof(NVIC->ICER) / 4; i++)
|
||||
NVIC->ICER[i] = ~(0UL);
|
||||
|
||||
#if defined(__ARM_ARCH_8M_MAIN__) || defined(__ARM_ARCH_8M_BASE__)
|
||||
/* Restore the Main Stack Pointer Limit register's reset value
|
||||
* before passing execution to runtime firmware to make the
|
||||
|
||||
@ -59,6 +59,7 @@ OF SUCH DAMAGE.
|
||||
#include "uart.h"
|
||||
#include "console.h"
|
||||
#include "flash_api.h"
|
||||
#include <radio_phy.h>
|
||||
|
||||
#ifdef CONFIG_TELNET_SERVER
|
||||
#include "telnet_main.h"
|
||||
@ -1093,6 +1094,8 @@ static void cmd_boot(int argc, char **argv)
|
||||
uint32_t arm_vector[2] = {0};
|
||||
uint32_t boot_idx = 0, image_offset = 0, version;
|
||||
|
||||
bRadioGoStandby();
|
||||
|
||||
if (argc > 2) {
|
||||
DEBUGPRINT("jump_bml: command format error!\r\n");
|
||||
goto Usage;
|
||||
|
||||
@ -33,6 +33,7 @@ OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*============================ INCLUDES ======================================*/
|
||||
#include "radio_hal.h"
|
||||
#include "wrapper_freertos.h"
|
||||
#include "wrapper_os.h"
|
||||
#include "debug_print.h"
|
||||
@ -145,12 +146,14 @@ void start_task(void *p_arg)
|
||||
const char *filename;
|
||||
#endif // CONFIG_GY3513
|
||||
|
||||
wifi_management_init();
|
||||
// wifi_management_init();
|
||||
#ifdef CONFIG_FATFS_SUPPORT
|
||||
rcu_periph_clock_enable(RCU_CRC);
|
||||
fatfs_mk_mount();
|
||||
#endif
|
||||
|
||||
delay1ms(100);
|
||||
|
||||
#ifdef CONFIG_CONSOLE_ENABLE
|
||||
console_init();
|
||||
#else
|
||||
@ -197,11 +200,11 @@ int main(void)
|
||||
}
|
||||
#endif // CONFIG_TASK_LED
|
||||
|
||||
if (NULL == sys_task_create(NULL, (const uint8_t *)"start_task", NULL, START_TASK_STK_SIZE, 0, START_TASK_PRIO, start_task, NULL)) {
|
||||
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");
|
||||
}
|
||||
|
||||
if (NULL == sys_task_create(NULL, (const uint8_t *)"sub1g_task", NULL, START_TASK_STK_SIZE, 0, START_TASK_PRIO, sub1g_task, NULL)) {
|
||||
if (NULL == sys_task_create(NULL, (const uint8_t *)"start_task", NULL, START_TASK_STK_SIZE, 0, START_TASK_PRIO, start_task, NULL)) {
|
||||
DEBUGPRINT("ERROR: create start task failed\r\n");
|
||||
}
|
||||
|
||||
|
||||
@ -149,6 +149,274 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#if ( PRODUCT_FREQUENCY == CM2310A_868MHZ)
|
||||
|
||||
const uint8_t g_cmt2310a_page0[CMT2310A_PAGE0_SIZE] = {
|
||||
0x2A,
|
||||
0x42,
|
||||
0x00,
|
||||
0xAA,
|
||||
0x04,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x64,
|
||||
0xD1,
|
||||
0xCE,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x64,
|
||||
0xD1,
|
||||
0xCE,
|
||||
0x1F,
|
||||
0x00,
|
||||
0x01,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x2D,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x2D,
|
||||
0x41,
|
||||
0x00,
|
||||
0x00,
|
||||
0xFF,
|
||||
0xFF,
|
||||
0x00,
|
||||
0x00,
|
||||
0x05,
|
||||
0x80,
|
||||
0x00,
|
||||
0x00,
|
||||
0x08,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x1F,
|
||||
0x07,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0xE4,
|
||||
0x20,
|
||||
0x1A,
|
||||
0x60,
|
||||
0x08,
|
||||
0x00,
|
||||
0xAA,
|
||||
0x00,
|
||||
0xE2,
|
||||
0x82,
|
||||
0x38,
|
||||
0x00,
|
||||
0xD0,
|
||||
0xE0,
|
||||
0x80,
|
||||
0x00,
|
||||
0x41,
|
||||
0x00,
|
||||
0x01,
|
||||
0x00,
|
||||
0x02,
|
||||
0x00,
|
||||
0x00,
|
||||
0x03,
|
||||
0x04,
|
||||
};
|
||||
|
||||
const uint8_t g_cmt2310a_page1[CMT2310A_PAGE1_SIZE] = {
|
||||
0x10,
|
||||
0x06,
|
||||
0x00,
|
||||
0xFF,
|
||||
0x00,
|
||||
0xCD, // vRadioTcxoDrvSel 接收设置的,将0xcd变为了0x0d
|
||||
0x0E,
|
||||
0x20,
|
||||
0x50,
|
||||
0x87,
|
||||
0x31,
|
||||
0x5B,
|
||||
0x08,
|
||||
0x38,
|
||||
0xFF,
|
||||
0x00,
|
||||
0x6C,
|
||||
0x00,
|
||||
0x00,
|
||||
0x08,
|
||||
0xB4,
|
||||
0x04,
|
||||
0x56,
|
||||
0xE0,
|
||||
0x20,
|
||||
0x08,
|
||||
0x01,
|
||||
0x10,
|
||||
0x11,
|
||||
0x00,
|
||||
0x91,
|
||||
0x7F,
|
||||
0x00,
|
||||
0x18,
|
||||
0x00,
|
||||
0x00,
|
||||
0x1F,
|
||||
0xE4,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0xC0,
|
||||
0x6C,
|
||||
0x00,
|
||||
0x80,
|
||||
0x98,
|
||||
0x6B,
|
||||
0x00,
|
||||
0x80,
|
||||
0x0F,
|
||||
0x64,
|
||||
0x06,
|
||||
0x02,
|
||||
0x04,
|
||||
0x56,
|
||||
0x00,
|
||||
0x36,
|
||||
0x05,
|
||||
0x20,
|
||||
0xC8,
|
||||
0x63,
|
||||
0xA1,
|
||||
0xFA,
|
||||
0x02,
|
||||
0x58,
|
||||
0x40,
|
||||
0x54,
|
||||
0x74,
|
||||
0xD0,
|
||||
0x0F,
|
||||
0x01,
|
||||
0x1B,
|
||||
0xE6,
|
||||
0x54,
|
||||
0x0C,
|
||||
0x09,
|
||||
0xE2,
|
||||
0x33,
|
||||
0x04,
|
||||
0x01,
|
||||
0xA5,
|
||||
0x06,
|
||||
0x0F,
|
||||
0x12,
|
||||
0x4C,
|
||||
0x00,
|
||||
0x00,
|
||||
0xF6,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x18,
|
||||
0x81,
|
||||
0x00,
|
||||
0x00,
|
||||
0x47,
|
||||
0x12, //0x67寄存器,ANT_DIVERSITY_MODE设置电线分集的接口会修改它
|
||||
0x25,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
};
|
||||
|
||||
/* [CMT page2] */
|
||||
const uint8_t g_cmt2310a_page2[CMT2310A_PAGE2_SIZE] = {
|
||||
0x00,
|
||||
0x01,
|
||||
0x02,
|
||||
0x03,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
};
|
||||
|
||||
#if 0
|
||||
/* [CMT page0] */
|
||||
const uint8_t g_cmt2310a_page0[CMT2310A_PAGE0_SIZE] = {
|
||||
0x12,
|
||||
@ -350,3 +618,4 @@ const uint8_t g_cmt2310a_page1[CMT2310A_PAGE1_SIZE] = {
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -21,6 +21,8 @@
|
||||
|
||||
#include "board.h"
|
||||
|
||||
#define GET_CHIP_INFO_RETRY_MAX 10
|
||||
|
||||
uint8_t rf_rxbuffer[200];
|
||||
uint8_t rf_rxsize;
|
||||
uint8_t radio_rece_data_flag;
|
||||
@ -29,28 +31,50 @@ extern uint32_t g_chip_id;
|
||||
|
||||
void Ebyte_E48x_Init( void )
|
||||
{
|
||||
int ret;
|
||||
uint8_t chip_state = 0;
|
||||
uint32_t fail_retry = 0;
|
||||
boolean_t is_chip_cmt2310 = FALSE;
|
||||
|
||||
vSpiMasterInit();
|
||||
|
||||
init_prepare:
|
||||
/* Step1 */
|
||||
g_chip_id = lRadioChipVersion();
|
||||
chip_state = bRadioGetState();
|
||||
// OSAL_LOGD("Debug, got information Version[%#X] State[%#X].", g_chip_id, chip_state);
|
||||
|
||||
is_chip_cmt2310 = ((g_chip_id & 0x00FFFF00) == 0x00231000);
|
||||
if (is_chip_cmt2310 && (chip_state == CMT2310A_STATE_IS_READY)) {
|
||||
DEBUGPRINT("Infor, CMT2310 already in State[READY], so skip initialization.");
|
||||
goto init_end;
|
||||
}
|
||||
else if (is_chip_cmt2310 && (!chip_state || chip_state & 0x80)) { // Valid mode, except IDLE and READY
|
||||
DEBUGPRINT("Debug, initialize CMT2310 right now with current State[%#X].", chip_state);
|
||||
goto init_run;
|
||||
}
|
||||
else if (fail_retry++ >= GET_CHIP_INFO_RETRY_MAX) {
|
||||
DEBUGPRINT("Error, get the information of CMT2310 failed with Chip-ID[%#X] State[%#X].", g_chip_id, chip_state);
|
||||
return -1;
|
||||
}
|
||||
else if (fail_retry == 1) {
|
||||
vRadioPowerUp(); // Release RST(GPIO5)
|
||||
vRadioSetAntSwitch(FALSE, FALSE); // Disable GPIO0 & GPIO1 as antenna switch control
|
||||
vRadioSpiModeSel(FALSE); // SPI 4-Wire mode
|
||||
delay1ms(20);
|
||||
}
|
||||
|
||||
/* Step2 */
|
||||
g_chip_id = lRadioChipVersion();
|
||||
if(0x00231000 != (g_chip_id & 0x00FFFF00)) {
|
||||
DEBUGPRINT("[%s|%u] Error, dismatch Chip-ID[%#x](!=0x231000).\r\n", __FUNCTION__, __LINE__, g_chip_id);
|
||||
return;
|
||||
}
|
||||
DEBUGPRINT("[%s|%u] Info, Link Device:E48-XXXM20S.\r\n", __FUNCTION__, __LINE__);
|
||||
vRadioSoftReset(); // Software reset
|
||||
vRadioBoot(); // Boot CMT2310 core
|
||||
delay1ms(50);
|
||||
|
||||
/* Step3 */
|
||||
if (bRadioGetState() == CMT2310A_STATE_IS_READY) {
|
||||
DEBUGPRINT("[%s|%u] Infor, CMT2310 already in State[READY], so skip initialization.\r\n", __FUNCTION__, __LINE__);
|
||||
return;
|
||||
}
|
||||
DEBUGPRINT("[%s|%u] Info, goto initialize E48-XXXM20S.\r\n", __FUNCTION__, __LINE__);
|
||||
|
||||
/* Step4 */
|
||||
goto init_prepare;
|
||||
init_run:
|
||||
/* Step3~6 */
|
||||
vRadioInit();
|
||||
|
||||
init_end:
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Ebyte_E48x_SendPayload( uint8_t *payload, uint8_t size, uint32_t timeout )
|
||||
|
||||
@ -430,6 +430,11 @@ void vRadioRegPageSel( uint8_t page_sel )
|
||||
}
|
||||
}
|
||||
|
||||
void vRadioBoot( void )
|
||||
{
|
||||
bSpiWriteByte( CMT2310A_CTL_REG_00, CMT2310A_REBOOT );
|
||||
}
|
||||
|
||||
/******************************
|
||||
**Name: vRadioPowerUpBoot
|
||||
**Func: Radio power up boot start
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
#define CM2310A_868MHZ 2
|
||||
#define CM2310A_915MHZ 3
|
||||
|
||||
#define PRODUCT_FREQUENCY CM2310A_410MHZ//ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>
|
||||
#define PRODUCT_FREQUENCY CM2310A_433MHZ//ѡ<><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5>
|
||||
|
||||
#include "radio_spi.h"
|
||||
#include "CMT2310A_def.h"
|
||||
@ -83,6 +83,8 @@ extern void vRadioXoWaitCfg( uint8_t div_sel );
|
||||
|
||||
extern void delay1ms(uint16_t cnt);
|
||||
extern void delay10us(uint32_t cnt);
|
||||
|
||||
extern void vRadioBoot( void );
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user