找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 12846|回复: 15
收起左侧

RDA5856代码开发手册 IOT蓝牙双模芯片源码与资料下载

  [复制链接]
ID:402760 发表于 2018-9-26 17:15 | 显示全部楼层 |阅读模式
紫光展锐旗下锐迪科微电子的蓝牙双模单芯片方案 RDA5856,该方案具有强大的音频处理和蓝牙连接功能,为蓝牙音响、车载终端、智能家居等消费电子市场提供普及型的物联网解决方案。

RDA5856 实现了蓝牙双模的 SOC,在单芯片上集成高性能 MCU、Bluetooth、FM Radio、PMU、Codec 及 Memory,支持V2.1(2.1+EDR)和 BLE 两种模式,并拥有丰富的接口资源,满足各类蓝牙产品的开发需求。

RDA5856 采用自主研发的降噪算法和回声抑制算法,蓝牙音乐播放的信噪比可以达到 -90dB 以上,同时该芯片具有优秀的射频灵敏度,BR 灵敏度达到 -94dBm 以上。RDA5856 具备强大的抗干扰和穿墙能力以及更持久的续航能力,适用于各种蓝牙音箱,头戴式耳机、声霸等多种应用场合。

RDA5856 已通过严格的蓝牙标准认证,取得了蓝牙 V4.2 的 QDID 证书。RDA 根据应用领域的不同推出了 TSSOP、LQFP、QFN 等多种封装形式,最大程度满足客户差异化需求。



5856_codec 注意事项:

烧写口
因为默认的debug口(P44,P45)和SD卡的clk和cmd线复用,所以如果要使用sd卡,就得通过板上的拨码开关来把默认的debug口换成P41,P42,原来debug口的pinmux改成function5.
Pinmux的配置可以在tgt_board_cfg.h中更改。

当不使用SD卡时,就可以把P44,P45的pinmux设成0.(默认的代码就是0)。拨码开关两个都拨到上端。
当使用SD卡时,就可以把P44,P45的pinmux设成5. 然后烧写时先把拨码开关拨到上端(只是延时了3s,所以按完reset键就得马上烧写),烧写成功后再把拨码开关都拨到下端。
另外因为芯片内部spi不通,所以需通过5855e板的I2C来设置5956板的pmu (5855e的I2C需用导线连接到5856的I2C2上)。




程序源码:
0.png

  1. /********************************************************************************
  2. *                RDA API FOR MP3HOST
  3. *
  4. *        (c) Copyright, RDA Co,Ld.
  5. *             All Right Reserved
  6. *
  7. ********************************************************************************/
  8. #include "ap_common.h"
  9. #include "ap_calendar.h"
  10. #include "ap_idle.h"
  11. #include "ap_linein.h"
  12. #include "ap_record.h"
  13. #include "ap_setting.h"
  14. #include "ap_fm.h"
  15. #include "ap_music.h"
  16. #include "ap_bluetooth.h"
  17. #include "ap_usbdisk.h"
  18. #include "ap_charging.h"
  19. #include "tm.h"
  20. #include "MainTask.h"
  21. #include "event.h"
  22. #include "gpio_edrv.h"

  23. #define READ_BUF_MAX          128
  24. #define MAIN_ITEMCOUNT        5  /*Main Menu Nums*/
  25. #define MAX_BOOT_LOGO_PICS    6  /*BootLogo Nums Used by User*/

  26. #define UPDATE_TFLASH_BIN_NAME  L"tflash_update.bin"


  27. static const UINT16 boot_logo_pic[MAX_BOOT_LOGO_PICS] = {GUI_IMG_LOGO, GUI_IMG_LOGO, GUI_IMG_LOGO, GUI_IMG_LOGO, GUI_IMG_LOGO, GUI_IMG_LOGO};

  28. ///////////////////////////////////////////////////////////////////////////////////
  29. comval_t         *g_comval; //系统总的环境变量
  30. slider_t         slider = {0};
  31. //function_menu_t  menu;
  32. //progress_t       progress;
  33. sysconfig_t      g_sysconfig = {0};
  34. displayconfig_t  g_displayconfig = {0};
  35. #if APP_SUPPORT_BLUETOOTH==1
  36. btconfig_t       g_btconfig = {0};
  37. #endif
  38. INT32           g_last_reslt = -1;
  39. INT32           g_current_module = 0;

  40. //////////////////////////////////////////////////////////////////////////////////

  41. //add by wuxiang
  42. extern UINT16 call_status;
  43. extern UINT32 g_bt_call_time;

  44. //add end
  45. extern BOOL ui_auto_update;
  46. extern BOOL ui_auto_select;
  47. extern BOOL g_test_mode;
  48. extern UINT8 g_usb_active_after_bt;
  49. UINT32 event_detected_displaying_log;
  50. extern UINT8 g_linein_out_event;
  51. extern UINT8 g_usb_audio_linein;
  52. extern UINT8 g_usb_audio_tcard;
  53. #if APP_SUPPORT_FADE_INOUT==1
  54. extern INT8 g_fade_volume_backup;
  55. #endif

  56. extern UINT32 musicplay_timer;

  57. void APP_Test_Mode(void);


  58. typedef INT32 (*MOD_FunCbPtr )(INT32 param);
  59. /* Mod Functions To Entry Every Mod By Special Satus  */
  60. static MOD_FunCbPtr currModFuncPtrs[MAX_FUNCTION_MOD];

  61. //Main Menu Picture Ids
  62. //static const UINT16 inactive_id[MAIN_ITEMCOUNT] = {GUI_IMG_MUSIC,  GUI_IMG_RECORD,  GUI_IMG_BT,  GUI_IMG_FM,  GUI_IMG_SYSTEM};
  63. //static const UINT16 active_id[MAIN_ITEMCOUNT]   = {GUI_IMG_MUSICA, GUI_IMG_RECORDA, GUI_IMG_BTA, GUI_IMG_FMA, GUI_IMG_SYSTEMA};
  64. //static const UINT16 item_str_id[MAIN_ITEMCOUNT] = {GUI_STR_MUSIC,  GUI_STR_RECORD,  GUI_STR_BT,  GUI_STR_FM,  GUI_STR_SETTING};

  65. //应用模块ID
  66. //static const UINT16 ap_id[MAIN_ITEMCOUNT]={RESULT_MUSIC, RESULT_RECORD_NOSTART,RESULT_BT, RESULT_RADIO, RESULT_SYSTEM};


  67. /*********************************************************************************
  68. * Description : 注册功能模块函数,提供外部调用
  69. *
  70. * Arguments   :
  71. *
  72. * Returns     :
  73. *
  74. * Notes       :
  75. *
  76. *********************************************************************************/
  77. INT32  APP_RegisterFunPtr(UINT8 mod, MOD_FunCbPtr cb)
  78. {
  79.         if(cb == NULL || mod > MAX_FUNCTION_MOD)
  80.         {
  81.                 return -1;
  82.         }
  83.         else
  84.         {
  85.                 currModFuncPtrs[mod] = cb;
  86.         }
  87.         return 1;
  88. }


  89. /*********************************************************************************
  90. * Description : 初始化注册函数
  91. *
  92. * Arguments   :
  93. *
  94. * Returns     :
  95. *
  96. * Notes       :
  97. *
  98. *********************************************************************************/
  99. INT32 APP_InitialFunPtr(void)
  100. {
  101.         INT32 i;
  102.        
  103.         for(i = 0; i <= MAX_FUNCTION_MOD; i++)
  104.         {
  105.                 currModFuncPtrs[i] = NULL;
  106.         }
  107.        
  108.         //注册各个模块的入口函数
  109. #if APP_SUPPORT_LCD==1
  110.         APP_RegisterFunPtr(FUN_CALENDAR,      CALENDAR_Entry);
  111.         APP_RegisterFunPtr(FUN_SYSTEM_SETTING, SET_Entry);
  112.         APP_RegisterFunPtr(FUN_TIMER, TIMER_Entry);
  113. #endif
  114. #if APP_SUPPORT_RECORD==1
  115.         APP_RegisterFunPtr(FUN_RECORD,        RECORD_Entry);
  116. #endif
  117. #if APP_SUPPORT_FM==1
  118.         APP_RegisterFunPtr(FUN_FM,            FM_Entry);
  119. #endif
  120. #if APP_SUPPORT_LINEIN==1
  121.         APP_RegisterFunPtr(FUN_LINEIN,        LINEIN_Entry);
  122. #endif
  123.         APP_RegisterFunPtr(FUN_IDLE,          IDLE_Entry);
  124. #if APP_SUPPORT_MUSIC==1
  125.         APP_RegisterFunPtr(FUN_MUSIC,         MUSIC_Entry);
  126. #endif
  127. #if APP_SUPPORT_USBDEVICE==1
  128.         APP_RegisterFunPtr(FUN_USB,           USB_Entry);
  129. #endif
  130. #if APP_SUPPORT_BLUETOOTH==1
  131.         APP_RegisterFunPtr(FUN_BT,            BT_Entry);
  132. #endif
  133.         APP_RegisterFunPtr(FUN_CHARGING,      Charging_Entry);
  134.         return 1;
  135. }

  136. /*********************************************************************************
  137. * Description : 注册功能模块函数,提供外部调用
  138. *
  139. * Arguments   :
  140. *
  141. * Returns     :
  142. *
  143. * Notes       :
  144. *
  145. *********************************************************************************/
  146. INT32 APP_ModCall(UINT8 mod, INT32 Param)
  147. {
  148.         hal_HstSendEvent(SYS_EVENT, 0x10140000 + mod);
  149.         g_current_module = mod;
  150.         if((mod < MAX_FUNCTION_MOD) && (currModFuncPtrs[mod] != NULL))
  151.         {
  152.                 return currModFuncPtrs[mod](Param);
  153.         }
  154.         return -1;
  155. }


  156. /*********************************************************************************
  157. * Description : 显示系统开机动画
  158. *
  159. * Arguments   : wait_key_up, 是否要等待按键
  160. *
  161. * Returns     : TRUE, 正常
  162.         FALSE, enter testmode
  163. *
  164. * Notes       :
  165. *
  166. *********************************************************************************/
  167. BOOL APP_DisplaySysLogo(BOOL wait_key_up)
  168. {
  169.         INT32 i, j;
  170.         BOOL keydown = FALSE;
  171.         UINT32 key;
  172.         UINT32 prekey = 0;
  173.         hal_HstSendEvent(SYS_EVENT, 0x19884501);
  174.         hal_HstSendEvent(SYS_EVENT, g_displayconfig.log_image_time);
  175.         hal_HstSendEvent(SYS_EVENT, g_displayconfig.log_image_count);
  176.         if(g_displayconfig.log_image_count == 0 && g_displayconfig.log_image_time == 0)
  177.         {
  178.                 for(i = 0; i < 1; i++)
  179.                         for(j = 0; j < 1;)
  180.                         {
  181.                                 key = MESSAGE_Wait();
  182.                                 //app_trace(APP_MAIN_TRC, "Display Log receive event 0x%x,prekey=0x%x, keydown=%d", key, prekey, keydown);
  183.                                 switch(key)
  184.                                 {
  185.                                 case AP_MSG_RTC:
  186.                                 case AP_MSG_CHARGING:
  187.                                         j++;
  188.                                         break;
  189.                                 default:
  190.                                         if((key & 0xffff) == AP_KEY_DOWN)
  191.                                         {
  192.                                                 if(prekey != 0 || key != (AP_KEY_DOWN | AP_KEY_POWER))
  193.                                                 {
  194.                                                         keydown = TRUE;
  195.                                                 }
  196.                                                 prekey = key;
  197.                                         }
  198.                                         if(keydown && (key & 0xffff) == AP_KEY_UP)
  199.                                         {
  200.                                                 return TRUE;
  201.                                         }
  202.                                        
  203.                                         key = MESSAGE_HandleHotkey(key);//handle unusual usb/t-card/line-in pluging event
  204.                                         if(key != 0)
  205.                                         {
  206.                                                 event_detected_displaying_log = key;
  207.                                                 hal_HstSendEvent(SYS_EVENT, 0x13063002);
  208.                                                 hal_HstSendEvent(SYS_EVENT, key);
  209.                                         }
  210.                                        
  211.                                         break;
  212.                                 }
  213.                         }
  214.         }
  215.        
  216.         for(i = 0; i < g_displayconfig.log_image_count; i++)
  217.         {
  218. #if APP_SUPPORT_RGBLCD==1
  219.                 if(AP_Support_LCD())
  220.                 {
  221.                         GUI_ClearScreen(NULL);//清全屏幕
  222.                         GUI_ResShowImage(GUI_IMG_LOGO, i, 0, 40); //g_displayconfig.log_x, g_displayconfig.log_y);/*BootLogo*/
  223.                         GUI_UpdateScreen(NULL);
  224.                 }
  225. #elif APP_SUPPORT_LCD==1
  226.                 if(AP_Support_LCD())
  227.                 {
  228.                         GUI_ClearScreen(NULL);//清全屏幕
  229.                         GUI_ResShowImage(GUI_IMG_LOGO, i, 0, 8); //g_displayconfig.log_x, g_displayconfig.log_y);/*BootLogo*/
  230.                         GUI_UpdateScreen(NULL);
  231.                 }
  232. #elif APP_SUPPORT_LED8S==1
  233.                 GUI_ClearScreen(NULL);
  234.                 GUI_ResShowPic(0xffff, 0, 0);
  235.                 GUI_DisplayText(0, 0, "8888");
  236.                 GUI_UpdateScreen(NULL);
  237. #endif
  238.                 hal_HstSendEvent(SYS_EVENT, 0x19884500);
  239.                 hal_HstSendEvent(SYS_EVENT, g_displayconfig.log_image_time);
  240.                 for(j = 0; j < g_displayconfig.log_image_time; )
  241.                 {
  242.                         key = MESSAGE_Wait();
  243.                         //app_trace(APP_MAIN_TRC, "Display Log receive event 0x%x,prekey=0x%x, keydown=%d", key, prekey, keydown);
  244.                         switch(key)
  245.                         {
  246.                         case AP_MSG_RTC:
  247.                         case AP_MSG_CHARGING:
  248.                                 j++;
  249.                                 break;
  250.                         default:
  251.                                 if((key & 0xffff) == AP_KEY_DOWN)
  252.                                 {
  253.                                         if(prekey != 0 || key != (AP_KEY_DOWN | AP_KEY_POWER))
  254.                                         {
  255.                                                 keydown = TRUE;
  256.                                         }
  257.                                         prekey = key;
  258.                                 }
  259.                                 if(keydown && (key & 0xffff) == AP_KEY_UP)
  260.                                 {
  261.                                         return TRUE;
  262.                                 }
  263.                                 break;
  264.                         }
  265.                 }
  266.         }
  267.        
  268.         return TRUE;
  269. }


  270. /*********************************************************************************
  271. * Description : 初始化系统设置变量
  272. *
  273. * Arguments   :
  274. *
  275. * Returns     :
  276. *
  277. * Notes       :
  278. *
  279. *********************************************************************************/
  280. void APP_ReadComPara(void)
  281. {
  282.         //DSM_ReadUserData();
  283.        
  284.         //NVRAMRead(g_comval, VM_SYSTEM, sizeof(g_comval));
  285.         g_comval = (comval_t*)NVRAMGetData(VM_SYSTEM, sizeof(comval_t));
  286.         hal_HstSendEvent(SYS_EVENT, 0x19880900);
  287.         if(g_comval->magic != MAGIC_COMVAL)
  288.         {
  289.                 hal_HstSendEvent(SYS_EVENT, 0x19880901);
  290.                 if(!LoadFactorySetting(g_comval, sizeof(g_comval)))
  291.                 {
  292.                         g_comval->DisplayContrast = 5;
  293.                         g_comval->langid    = GUI_LANG_SM_CHINESE;
  294.                         g_comval->LightTime = 3;
  295.                         //g_comval->ReplayMode = 0;
  296.                         //g_comval->SleepTime = 0;
  297.                         g_comval->StandbyTime = 30;
  298.                         //g_comval->BatteryType = BATT_TYPE_ALKALINE;
  299.                         //g_comval->FMBuildInFlag = 0;
  300.                         //g_comval->RecordType = 0;
  301.                         //g_comval->BLightColor = 3;
  302.                         g_comval->BackLight = 5;
  303.                         g_comval->Volume = 8; // default volume
  304.                        
  305.                         g_comval->music_cfg.loop_mode = 0;
  306.                         g_comval->music_cfg.eq_mode = 0;
  307.                         g_comval->music_cfg.repeat_count = 3;
  308.                         g_comval->music_cfg.repeat_time = 30;
  309.                        
  310. #if APP_SUPPORT_FM==1           /*Surport fm*/
  311.                         g_comval->fm_value.fm_band = 0;
  312.                         g_comval->fm_value.fm_sendfreq = 1000;
  313. #endif
  314.                 }
  315.                 hal_HstSendEvent(SYS_EVENT, 0x19880902);
  316.                 g_comval->magic     = MAGIC_COMVAL;
  317.                 // no need save data
  318.                 //NVRAMWrite(g_comval, VM_SYSTEM,sizeof(g_comval));
  319.                
  320.                 //g_test_mode = 1;
  321.         }
  322.        
  323.         if(!ReadConfigData(&g_sysconfig, CFG_SYSTEM, sizeof(g_sysconfig)))
  324.         {
  325.                 g_sysconfig.AppSupportFlag = AP_SUPPORT_RECORD | (AP_SUPPORT_FM * APP_SUPPORT_FM) | (AP_SUPPORT_FMREC * APP_SUPPORT_FM_RECORD) | (AP_SUPPORT_LCD * APP_SUPPORT_LCD) | (AP_SUPPORT_MENU * APP_SUPPORT_MENU) | (AP_SUPPORT_LED * APP_SUPPORT_LED);
  326.         }
  327. #if APP_SUPPORT_RGBLCD==1
  328.         if(AP_Support_LCD() && !ReadConfigData(&g_displayconfig, CFG_DISPLAY, sizeof(g_displayconfig)))
  329.         {
  330.                 g_displayconfig.lcd_heigth = 128;
  331.                 g_displayconfig.lcd_width = 160;
  332.                 //g_displayconfig.log_x = 0;
  333.                 //g_displayconfig.log_y = 8;
  334.                 //g_displayconfig.usb_x = 0;
  335.                 //g_displayconfig.usb_y = 16;
  336.                
  337.                 g_displayconfig.big_num_width = 16;
  338.                 g_displayconfig.big_colon_width = 9;
  339.                 g_displayconfig.small_num_width = 6;
  340.                 g_displayconfig.small_colon_width = 4;
  341.                
  342.                 //g_displayconfig.num_key_img = GUI_IMG_BIG_NUM;
  343.                 //g_displayconfig.num_key_x = 32;
  344.                 //g_displayconfig.num_key_y = 16;
  345.                
  346.                 g_displayconfig.position_batt = POSITION_BATT;
  347.                 g_displayconfig.message_y = 48;
  348.         }
  349. #elif APP_SUPPORT_LCD==1
  350.         if(AP_Support_LCD() && !ReadConfigData(&g_displayconfig, CFG_DISPLAY, sizeof(g_displayconfig)))
  351.         {
  352.                 g_displayconfig.lcd_heigth = 64;
  353.                 g_displayconfig.lcd_width = 128;
  354.                 //g_displayconfig.log_x = 0;
  355.                 //g_displayconfig.log_y = 8;
  356.                 //g_displayconfig.usb_x = 0;
  357.                 //g_displayconfig.usb_y = 16;
  358.        
  359.                 g_displayconfig.big_num_width = 16;
  360.                 g_displayconfig.big_colon_width = 9;
  361.                 g_displayconfig.small_num_width = 6;
  362.                 g_displayconfig.small_colon_width = 4;
  363.        
  364.                 //g_displayconfig.num_key_img = GUI_IMG_BIG_NUM;
  365.                 //g_displayconfig.num_key_x = 32;
  366.                 //g_displayconfig.num_key_y = 16;
  367.        
  368.                 g_displayconfig.position_batt = POSITION_BATT;
  369.                 g_displayconfig.message_y = 24;
  370.         }
  371. #endif
  372. #if APP_SUPPORT_BLUETOOTH==1     /*Surport bt*/
  373.         if(!ReadConfigData(&g_btconfig, CFG_BLUETOOTH, sizeof(g_btconfig)))
  374.         {
  375.                 strcpy(g_btconfig.local_name, "RDA MP3 BT"); // bluetooth name
  376.                 strcpy(g_btconfig.password, "0000");         // bluetooth password
  377.         }
  378. #endif
  379.         //SetBackLightColor(g_comval->BLightColor);        //设置背光颜色。
  380.        
  381.         SetBackLight(g_comval->BackLight);
  382.        
  383.         SetContrast(g_comval->DisplayContrast);           //设置屏幕的对比度
  384.        
  385.         MESSAGE_Initial(g_comval);
  386.        
  387. }


  388. INT32 APP_StandBy(void)
  389. {
  390.         UINT32 key;
  391.         INT wakeup = 0;
  392.        
  393.         GUI_DisplayMessage(0, GUI_STR_STANDBY, NULL, GUI_MSG_FLAG_WAIT);
  394.        
  395.         if(AP_Support_LCD())
  396.         {
  397.                 GUI_ClearScreen(NULL);//清全屏幕
  398.                 GUI_UpdateScreen(NULL);
  399.                 CloseBacklight();
  400.         }
  401.         ui_auto_update = FALSE;
  402.        
  403.         //APP_Sleep();
  404. #ifdef XDL_35uA_POWEROFF//warkey 2.1  //进入超低电流关机
  405.         rfd_XcvRegForceWrite32k();
  406. #endif
  407.         while(1)
  408.         {
  409.                 key = MESSAGE_Wait();
  410.                 if(key == AP_MSG_RTC && GetBattery() >= 0)
  411.                 {
  412.                         if(tgt_GetKeyCode(0) == KEY_POWER)
  413.                         {
  414.                                 app_trace(APP_MAIN_TRC, "APP_StandBy call DM_DeviceSwithOff");
  415.                                 DM_DeviceSwithOff();
  416.                         }
  417.                         else // 如果power键长高,无法关机,进入睡眠
  418.                         {
  419.                                 app_trace(APP_MAIN_TRC, "APP_StandBy call APP_Sleep");
  420.                                 APP_Sleep();
  421.                         }
  422.                         continue;
  423.                 }
  424.                 if(key == (AP_KEY_POWER | AP_KEY_PRESS))
  425.                 {
  426.                         wakeup = 1;
  427.                 }
  428.                 if(key == (AP_KEY_PLAY | AP_KEY_HOLD))
  429.                         if(MESSAGE_IsHold())
  430.                         {
  431.                                 wakeup = 1;
  432.                         }
  433.                 if((key & 0xffff) == AP_KEY_UP && wakeup)
  434.                 {
  435.                         key = RESULT_POWERON;
  436.                         break;
  437.                 }
  438.                 if(key == AP_MSG_ALARM)
  439.                 {
  440.                         key = RESULT_ALARM;
  441.                         break;
  442.                 }
  443.         }
  444.         APP_Wakeup();
  445.         return key;
  446. }

  447. #if APP_SUPPORT_CALIB_KEY==1
  448. INT32 APP_CalibKey(void)
  449. {
  450.         UINT32 key;
  451.        
  452. #ifdef _USED_TSC_KEY_
  453.         GUI_DisplayMessage(0, GUI_STR_CALIBKEY, NULL, GUI_MSG_FLAG_DISPLAY);
  454.         while(1)
  455.         {
  456.                 tsd_Key_Calib(0); // start
  457.                 key = MESSAGE_Wait();
  458.                 if((key & 0xffff) == AP_KEY_UP)
  459.                 {
  460.                         break;
  461.                 }
  462.         }
  463.        
  464.         LED_SetPattern(GUI_LED_CALIB_KEY1, LED_LOOP_INFINITE);
  465.         GUI_DisplayMessage(0, GUI_STR_CALIBKEY_1, NULL, GUI_MSG_FLAG_DISPLAY);
  466.         while(1)
  467.         {
  468.                 key = MESSAGE_Wait();
  469.                 if((key & 0xffff) == AP_KEY_UP)
  470.                 {
  471.                         break;
  472.                 }
  473.         }
  474.         tsd_Key_Calib(1); // first key press
  475.         LED_SetPattern(GUI_LED_CALIB_KEYN, LED_LOOP_INFINITE);
  476.         GUI_DisplayMessage(0, GUI_STR_CALIBKEY_N, NULL, GUI_MSG_FLAG_DISPLAY);
  477.         while(1)
  478.         {
  479.                 key = MESSAGE_Wait();
  480.                 if((key & 0xffff) == AP_KEY_UP)
  481.                 {
  482.                         break;
  483.                 }
  484.         }
  485.         key = tsd_Key_Calib(2); // last key press
  486.         if(key == 0)
  487.         {
  488.                 LED_SetPattern(GUI_LED_NONE, 0);
  489.                 GUI_DisplayMessage(0, GUI_STR_CALIBKEY_SUCC, NULL, GUI_MSG_FLAG_WAIT);
  490.         }
  491.         else
  492.         {
  493.                 GUI_DisplayMessage(0, GUI_STR_CALIBKEY_FAIL, NULL, GUI_MSG_FLAG_WAIT);
  494.         }
  495. #endif
  496.         return 0;
  497. }
  498. #endif

  499. BOOL APP_Read_Sys_Config(void)
  500. {
  501. #if 0
  502.         //////////////////////Set Para Through File//////////////////////////
  503.         INT32 config_file_handle = 0;
  504.         UINT8 buf[READ_BUF_MAX];
  505.         if(MountDisk(FS_DEV_TYPE_TFLASH))
  506.         {
  507.                 config_file_handle = FS_Open(L"Config.txt", FS_O_RDONLY, 0);
  508.         }
  509. #if APP_SUPPORT_USB
  510.         else if(MountDisk(FS_DEV_TYPE_USBDISK))
  511.         {
  512.                 config_file_handle = FS_Open("Config.txt", FS_O_RDONLY, 0);
  513.         }
  514. #endif
  515.         else
  516.         {
  517.                 return FALSE;
  518.         }
  519.        
  520.         if(config_file_handle < 0)
  521.         {
  522.                 return FALSE;
  523.         }
  524.        
  525.         ///////Scan Param For  Setting/////
  526.         memset(buf, 0, sizeof(buf));
  527.        
  528.         buf[READ_BUF_MAX - 1] = '\n';
  529.        
  530.         if(FS_Read(config_file_handle, buf, (sizeof(buf) - 1)))
  531.         {
  532.                 //kval_t kval;
  533.                 UINT16 uYear, uMonth, uDay, uHour, uMinute, uSecond, position;
  534.                
  535.                 /*First1:parse DATA*/
  536.                 {
  537.                         INT8 *str = "DATE:" ;
  538.                         position =  strstr(buf, str) - buf;
  539.                         position += strlen(str);
  540.                         uYear        = (buf[position] - '0') * 1000 + (buf[position + 1] - '0') * 100 + (buf[position + 2] - '0') * 10 + (buf[position + 3] - '0'); /*buf[0-3],Year... etc 2011 */
  541.                         uMonth        = (buf[position + 4] - '0') * 10 + (buf[position + 5] - '0'); /*buf[4-5],Month... etc 11 */
  542.                         uDay            = (buf[position + 6] - '0') * 10 + (buf[position + 7] - '0'); /*buf[6-7],Day...        etc 11 */
  543.                         str = "TIME:" ;
  544.                         position =  strstr(buf, str) - buf;
  545.                         position += strlen(str);
  546.                         uHour        = (buf[position] - '0') * 10  + (buf[position + 1] - '0'); /*buf[8-9],uHour... etc 11 */
  547.                         uMinute = (buf[position + 2] - '0') * 10 + (buf[position + 3] - '0'); /*buf[10-11],uMinute... etc 11 */
  548.                         uSecond = (buf[position + 4] - '0') * 10 + (buf[position + 5] - '0'); /*buf[12-13],uSecond... etc 21 */
  549.                 }
  550.                
  551.                 app_trace(APP_MAIN_TRC, "[APP_Read_Sys_Config]:%d,%d,%d,%d,%d,%d\r\n", uYear, uMonth, uDay, uHour, uMinute, uSecond);
  552.                
  553.                
  554.                 /*Get Band,FMFREQ*/
  555. #if APP_SUPPORT_FM==1           /*Surport fm*/
  556.                 {
  557.                         INT8 *str = "BAND:" ;
  558.                         position =  strstr(buf, str) - buf;
  559.                         position += strlen(str);
  560.                         g_comval->fm_value.fm_band = (buf[position] - '0');
  561.                         str = "FMSEND:" ;
  562.                         position =  strstr(buf, str) - buf;
  563.                         position += strlen(str);
  564.                         g_comval->fm_value.fm_sendfreq = (buf[position] - '0') * 1000 + (buf[position + 1] - '0') * 100 + (buf[position + 2] - '0') * 10 + (buf[position + 3] - '0');
  565.                 }
  566. #endif
  567.                 /*Get Loop,Eq*/
  568.                 {
  569.                         INT8 *str = "LOOP:" ;
  570.                         position =        strstr(buf, str) - buf;
  571.                         position += strlen(str);
  572.                         g_comval->music_cfg.loop_mode = (buf[position] - '0');
  573.                         str = "EQ:" ;
  574.                         position =        strstr(buf, str) - buf;
  575.                         position += strlen(str);
  576.                         g_comval->music_cfg.eq_mode   = (buf[position] - '0');
  577.                 }
  578.                 /*Get repeat ,times*/
  579.                 {
  580.                         INT8 *str = "REPEAT:" ;
  581.                         position =        strstr(buf, str) - buf;
  582.                         position += strlen(str);
  583.                         g_comval->music_cfg.repeat_count = (buf[position] - '0');
  584.                         str = "REPETIME:" ;
  585.                         position =        strstr(buf, str) - buf;
  586.                         position += strlen(str);
  587.                         g_comval->music_cfg.repeat_time         = (buf[position] - '0') * 10 + (buf[position + 1] - '0');
  588.                 }
  589.                
  590.                 //将systemtime 和 gwtime写回到VRAM中
  591.                 //NVRAMRead(&kval, VM_KERNEL, sizeof(kval_t));
  592.                 //kval.systemtime = ((uYear-2000)*365+uMonth*30+uDay)*24*60+uHour*60+uMinute;         //全局变量
  593.                 //NVRAMWrite(&kval, VM_KERNEL, sizeof(kval_t));
  594.                
  595.         }
  596.        
  597.         FS_Close(config_file_handle);
  598. #endif
  599.         return TRUE;
  600. }

  601. INT32 main_menu_callback(INT32 type, INT32 value, INT32 param, UINT8 **string)
  602. {
  603.         if(MENU_CALLBACK_QUERY_ACTIVE == type)
  604.         {
  605.                 return g_last_reslt;
  606.         }
  607.         return FALSE;
  608. }


  609. TASK_ENTRY BAL_MainTaskEntry(void *pData)
  610. {
  611.         INT8   IsUDisk = 0;
  612.         BOOL   need_draw = TRUE;
  613.         INT32  active = 0;   //当前活动的项目
  614.         INT32  result = APP_DEFAULT_RESULT;
  615.         INT32  ret    = RESULT_NULL;
  616.         INT32  bt_active_ret = RESULT_NULL;
  617.         TM_SYSTEMTIME systime;
  618.         extern BOOL g_usb_connected;
  619.        
  620.         // dump version and date
  621.         //hal_HstSendEvent(SYS_EVENT,0x11223344);
  622.         //hal_HstSendEvent(SYS_EVENT,GetPlatformVersion());
  623.         //hal_HstSendEvent(SYS_EVENT,GetPlatformRevision());
  624.         //hal_HstSendEvent(SYS_EVENT,GetPlatformBuildDate());
  625.         //hal_HstSendEvent(SYS_EVENT,AP_GetVersion());
  626.         //hal_HstSendEvent(SYS_EVENT,AP_GetBuildDate());
  627.        
  628.         APP_ReadComPara();        //读取系统的全局变量。可以放在os初始化的过程中做
  629. #if XDL_APP_SUPPORT_LOWBAT_DETECT==1//warkey 2.1
  630.         StartBatTimer();
  631. #endif
  632.         gui_load_resource(g_comval->langid);
  633.        
  634.         LED_SetPattern(GUI_LED_POWERON, 1);
  635.        
  636. #if APP_SUPPORT_LCD==1
  637.         if(AP_Support_LCD())
  638.         {
  639.                 lcdd_Open();
  640.                 GUI_Initialise(g_displayconfig.lcd_width, g_displayconfig.lcd_heigth);
  641.                 GUI_SetTextColor(g_displayconfig.font_color);
  642.                 GUI_SetBackColor(g_displayconfig.back_color);
  643.         }
  644. #endif
  645.        
  646.         if(g_test_mode)
  647.         {
  648.                 NVRAMWriteData();
  649.                 APP_Test_Mode();
  650.         }
  651.        
  652.         APP_DisplaySysLogo(FALSE);
  653.         AP_GetBuildDate();//force link date time functions.
  654.        
  655.         // check systemtime
  656.         TM_GetSystemTime(&systime);
  657.         if(systime.uHour >= 24 || systime.uDay == 0 || systime.uYear > 2050) // invalid date time
  658.         {
  659.                 systime.uYear = 2012;
  660.                 systime.uMonth = 8;
  661.                 systime.uDay = 15;
  662.                 systime.uHour = 12;
  663.                 systime.uMinute = 30;
  664.                 TM_SetSystemTime(&systime);
  665.         }
  666. #if APP_SUPPORT_LCD==1
  667.         TIMER_SetAlarm(1);
  668. #endif
  669.        
  670.         hal_HstSendEvent(SYS_EVENT, 0x09250001);
  671.        
  672.         APP_InitialFunPtr(); //初始化各个模块的回调函数,最后通过宏定义来实现开关
  673.        
  674.         APP_Read_Sys_Config();
  675.         LED_SetPattern(GUI_LED_NONE, 1);
  676.        
  677.         hal_HstSendEvent(BOOT_EVENT, 0x09558000);
  678.        
  679. #if APP_SUPPORT_LCD==0  //added for T_card update without LCD. Search TF card, if there is a file with the name "tflash_update.bin", then do the update.
  680. #ifdef MCD_TFCARD_SUPPORT
  681.         {
  682.                 INT32 file = -1, card_ok = -1;
  683.                 UINT32 cur_data = AP_GetBuildDate();
  684.                 UINT32 cur_time = AP_GetBuildTime();
  685.                 boolean needupdate = FALSE;
  686.                
  687.                 hal_HstSendEvent(BOOT_EVENT, 0x98880001);
  688.                 hal_HstSendEvent(BOOT_EVENT, cur_data);
  689.                 hal_HstSendEvent(BOOT_EVENT, cur_time);
  690.                 hal_HstSendEvent(BOOT_EVENT, 0x98880001);
  691.                
  692.                
  693.                 card_ok = FS_MountDevice(FS_DEV_TYPE_TFLASH);
  694.                 hal_HstSendEvent(BOOT_EVENT, card_ok);
  695.                 if(card_ok == ERR_SUCCESS)
  696.                 {
  697.                         FS_FILE_ATTR file_attr;
  698.                         TM_FILETIME sFileTime;
  699.                         TM_SYSTEMTIME sSysTm;
  700.                         UINT32 bin_createDate = 0;
  701.                         UINT32 bin_createTime = 0;
  702.                         UINT32 offset = 0;
  703.                        
  704.                         file = FS_Open(UPDATE_TFLASH_BIN_NAME, FS_O_RDWR, 0);
  705.                        
  706.                         hal_HstSendEvent(BOOT_EVENT, 0x09550000);
  707.                         hal_HstSendEvent(BOOT_EVENT, file);
  708.                         hal_HstSendEvent(BOOT_EVENT, 0x09550000);
  709.                        
  710. #if 1
  711.                         FS_Seek(file, 0xc, FS_SEEK_SET);
  712.                         FS_Read(file, &offset, 4);
  713.                         FS_Seek(file, ((offset & 0x00ffffff)) - 0x10, FS_SEEK_SET);
  714.                         FS_Read(file, &bin_createDate, 4);
  715.                         FS_Read(file, &bin_createTime, 4);
  716.                        
  717.                         hal_HstSendEvent(BOOT_EVENT, 0x98880002);
  718.                         hal_HstSendEvent(BOOT_EVENT, bin_createDate);
  719.                         hal_HstSendEvent(BOOT_EVENT, bin_createTime);
  720.                         hal_HstSendEvent(BOOT_EVENT, 0x98880002);
  721. #else
  722.                         if(FS_GetFileAttrByHandle(file, &file_attr) == 0)
  723.                         {
  724.                                 sFileTime.DateTime = file_attr.i_mtime;
  725.                        
  726.                                 TM_FileTimeToSystemTime(sFileTime, &sSysTm);
  727.                                 bin_createDate = ((sSysTm.uYear) * 10000 + ((sSysTm.uMonth) * 100) + sSysTm.uDay);
  728.                                 bin_createTime = sSysTm.uHour * 10000 + sSysTm.uMinute * 100 + sSysTm.uSecond;
  729.                        
  730.                                 hal_HstSendEvent(BOOT_EVENT, 0x98880002);
  731.                                 hal_HstSendEvent(BOOT_EVENT, bin_createDate);
  732.                                 hal_HstSendEvent(BOOT_EVENT, bin_createTime);
  733.                                 hal_HstSendEvent(BOOT_EVENT, 0x98880002);
  734.                         }
  735. #endif
  736.                        
  737.                         //if((cur_data<bin_createDate) ||
  738.                         //(cur_data==bin_createDate && cur_time<bin_createTime))
  739.                         if((cur_data != bin_createDate) || (cur_time != bin_createTime)) //只要不是同一软件就允许升级
  740.                         {
  741.                                 needupdate = TRUE;
  742.                         }
  743.                        
  744.                         hal_HstSendEvent(BOOT_EVENT, needupdate);
  745.                         hal_HstSendEvent(BOOT_EVENT, 0x98880008);
  746.                        
  747.                         if(file >= 0 && needupdate)
  748.                         {
  749.                                 Upgrade_Flash(file);
  750.                                
  751.                                 RestartSystem();
  752.                         }
  753.                         else
  754.                         {
  755.                                 FS_Close(file);
  756.                         }
  757.                 }
  758.         }
  759. #endif
  760. #endif
  761.        
  762.        
  763.         g_last_reslt = result;
  764.         if(GetUsbCableStatus())
  765.         {
  766.                 hal_HstSendEvent(APP_EVENT, 0x13113001);
  767.                 result = RESULT_UDISK;
  768.         }
  769.         if(gpio_detect_linein() == GPIO_DETECTED)
  770.         {
  771.                 hal_HstSendEvent(APP_EVENT, 0x13113002);
  772.                 result = RESULT_LINE_IN;
  773.         }
  774.         //    IsUDisk = g_comval->Onlinedev;
  775.        
  776. #ifdef SUPPORT_POWERON_ENTER_CHARGE_AP//warkey 2.1
  777.         app_trace(APP_MAIN_TRC, "GetBattery:%d", GetBattery());
  778.         if(-1 == GetBattery() && g_usb_connected == 0)
  779.         {
  780.                 //                  hal_HstSendEvent(SYS_EVENT, 0x13062707);
  781.                 hal_HstSendEvent(APP_EVENT, 0x13113003);
  782.                 result = Charging_Entry();
  783.         }
  784. #endif
  785.         while(1)
  786.         {
  787.                 if(result==RESULT_STANDBY)
  788.                 {
  789.                         LED_SetPattern(GUI_LED_NONE, 0xde);
  790.                 }
  791.                 else
  792.                 {
  793.                         LED_SetPattern(GUI_LED_NONE, 1);
  794.                 }
  795.                
  796.                 hal_HstSendEvent(SYS_EVENT, 0x09250002);
  797.                 hal_HstSendEvent(SYS_EVENT, result);
  798.                
  799.                 if(result == RESULT_NULL || result == RESULT_MAIN)
  800.                 {
  801. #if APP_SUPPORT_MENU==1
  802.                         if(AP_Support_MENU())
  803.                         {
  804.                                 ui_auto_select = FALSE;
  805.                                 result = GUI_Display_Menu(GUI_MENU_MAIN, main_menu_callback);
  806.                                
  807.                                 g_last_reslt        = RESULT_NULL;
  808.                                 if(result == RESULT_TIMEOUT || result == RESULT_IGNORE || result == RESULT_NULL)
  809.                                 {
  810.                                         result = RESULT_IDLE; // RESULT_CALENDAR;
  811.                                 }
  812.                         }
  813.                         else
  814. #endif
  815.                         {
  816.                                 if(RESULT_STANDBY != result)
  817.                                 {
  818.                                         result = g_last_reslt;
  819.                                 }
  820.                                 switch(result)
  821.                                 {
  822.                                 case RESULT_STANDBY:
  823.                                         break;
  824.                                 case RESULT_BT:
  825. #if APP_SUPPORT_MUSIC==1
  826.                                         result = RESULT_MUSIC;
  827.                                         break;
  828.                                 case RESULT_MUSIC:
  829. #endif
  830. #if APP_SUPPORT_FM || APP_SUPPORT_LINEIN
  831.                                         //没有Line in时才进入FM 2012-9-27
  832.                                         if(gpio_detect_linein() == GPIO_DETECTED)
  833.                                         {
  834.                                 #if APP_SUPPORT_LINEIN ==1       
  835.                                                 result = RESULT_LINE_IN;
  836.                                                 break;
  837.                                 #else
  838.                                                 result = RESULT_RADIO;
  839.                                                 break;                                               
  840.                                 #endif
  841.                                         }
  842.                                         else
  843.                                         {
  844.                                 #if APP_SUPPORT_FM==1
  845.                                                 result = RESULT_RADIO;
  846.                                                 break;
  847.                                 #endif
  848.                                         }
  849.                                 case RESULT_LINE_IN:
  850.                                 case RESULT_RADIO:
  851. #endif
  852.                                
  853. #if APP_SUPPORT_RECORD
  854.                                         if(AP_Support_RECORD())
  855.                                         {
  856.                                                 result = RESULT_RECORD_NOSTART;
  857.                                                 break;
  858.                                         }
  859.                                 case RESULT_RECORD_NOSTART:
  860. #endif
  861. #if APP_SUPPORT_BLUETOOTH
  862.                                         result = RESULT_BT;
  863.                                         break;
  864. #endif
  865.                                 default:
  866.                                         result = APP_DEFAULT_RESULT;
  867.                                         break;
  868.                                 }
  869.                         }
  870.                 }
  871.                 else if(result == RESULT_POWERON)
  872.                 {
  873.                         if(AP_Support_LCD())
  874.                         {
  875.                                 GUI_ClearScreen(NULL);
  876.                                 GUI_UpdateScreen(NULL);
  877.                         }
  878.                         LED_SetPattern(GUI_LED_POWERON, 1);
  879.                        
  880.                         APP_DisplaySysLogo(TRUE);
  881.                         LED_SetPattern(GUI_LED_NONE, 1);
  882.                        
  883.                         if (g_comval->LightTime == 0)            //每次开机判断一次!解决Bug Report:27
  884.                         {
  885.                                 CloseBacklight();
  886.                         }
  887.                         else
  888.                         {
  889.                                 OpenBacklight();
  890.                         }
  891.                        
  892.                         //APP_DUMP("g_last_reslt:", g_last_reslt);
  893.                        
  894.                         result = g_last_reslt;
  895.                         if(GetUsbCableStatus())
  896.                         {
  897.                                 hal_HstSendEvent(APP_EVENT, 0x07021549);
  898.                                 result = RESULT_UDISK;
  899.                         }
  900.                         if(gpio_detect_linein() == GPIO_DETECTED)
  901.                         {
  902.                                 hal_HstSendEvent(APP_EVENT, 0x07021550);
  903.                                 result = RESULT_LINE_IN;
  904.                         }
  905.                         need_draw = TRUE;
  906.                 }
  907.                 else        //boot with param or result != 0
  908.                 {
  909.                         switch( result)
  910.                         {
  911. #if APP_SUPPORT_MUSIC==1
  912.                         case RESULT_MUSIC:
  913.                                 hal_HstSendEvent(SYS_EVENT, 0x20120000);
  914.                                 ret = APP_ModCall(FUN_MUSIC, 0);
  915.                                 g_last_reslt = result;
  916.                                 result = ret;
  917. #if APP_SUPPORT_FADE_INOUT==1
  918.                                 if(g_fade_volume_backup != -1)
  919.                                 {
  920.                                         //                    hal_HstSendEvent(SYS_EVENT, 0x13101701);
  921.                                         //                    hal_HstSendEvent(SYS_EVENT, g_fade_volume_backup);
  922.                                         SetPAVolume(g_fade_volume_backup);
  923.                                         g_fade_volume_backup = -1;
  924.                                 }
  925. #endif
  926.                                 if(g_usb_audio_tcard&&GetUsbCableStatus())//plug in tcard when usb audio is running
  927.                                 {
  928.                                         result = RESULT_UDISK;
  929.                                 }
  930.                                 hal_HstSendEvent(SYS_EVENT, 0x20124444);
  931.                                 hal_HstSendEvent(SYS_EVENT, g_last_reslt);
  932.                                 hal_HstSendEvent(SYS_EVENT, result);
  933.                                 break;
  934. #endif
  935.                         case RESULT_RADIO:
  936.                                 hal_HstSendEvent(SYS_EVENT, 0x20120033);
  937.                                 ret = APP_ModCall(FUN_FM, 0);
  938.                                 hal_HstSendEvent(SYS_EVENT, 0x20120044);
  939.                                 g_last_reslt = result;
  940.                                 result = ret;
  941.                                 hal_HstSendEvent(SYS_EVENT, 0x20123001);
  942.                                 break;
  943.                                
  944.                         case RESULT_RECORD_START:    //进入录音
  945.                         case RESULT_RECORD_NOSTART:
  946.                         case RESULT_FMREC_START:
  947.                         case RESULT_FMREC_NOSTART:
  948.                                 ret = APP_ModCall(FUN_RECORD, result); //传入result,以判断是否直接开始FM录音?
  949.                                 …………
  950. …………
  951. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

5856截图.PNG

全部资料51hei下载地址:
开发手册: RDA5856开发文档.zip (3.25 MB, 下载次数: 328)

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

ID:402999 发表于 2018-9-27 09:37 | 显示全部楼层
支持一下看看
回复

使用道具 举报

ID:419143 发表于 2018-11-1 15:16 | 显示全部楼层
打个点,等黑币够了再来下
回复

使用道具 举报

ID:136083 发表于 2018-11-23 15:32 | 显示全部楼层
大佬,你自己看过没有,这代码不是5856的哈。
回复

使用道具 举报

ID:185161 发表于 2019-4-13 23:42 | 显示全部楼层
这个芯片资料好少啊。厂家官网都打不开。。
回复

使用道具 举报

ID:589216 发表于 2019-7-23 20:14 | 显示全部楼层
资料好少啊
回复

使用道具 举报

ID:196917 发表于 2019-8-16 13:16 | 显示全部楼层
没有包含硬件资料
回复

使用道具 举报

ID:601446 发表于 2019-9-10 17:32 来自手机 | 显示全部楼层
正好需要这个资料啊,谢谢楼主
回复

使用道具 举报

ID:219315 发表于 2019-9-19 21:03 | 显示全部楼层
谢谢楼主!!!!!
回复

使用道具 举报

ID:619051 发表于 2019-10-3 19:05 | 显示全部楼层
谢谢楼主 正需要呢
回复

使用道具 举报

ID:160131 发表于 2019-12-6 09:35 | 显示全部楼层
你好,可以请教你一个问题吗
回复

使用道具 举报

ID:476744 发表于 2019-12-15 09:00 | 显示全部楼层
不错,很好的资料
回复

使用道具 举报

ID:232306 发表于 2020-10-5 10:45 | 显示全部楼层
已经下载,多谢楼主
回复

使用道具 举报

ID:232306 发表于 2020-10-5 10:50 | 显示全部楼层
开发环境怎么搭建?
回复

使用道具 举报

ID:486587 发表于 2021-10-16 12:03 | 显示全部楼层
正好需要这个资料,如果有SDK就更好了
回复

使用道具 举报

ID:1036193 发表于 2023-5-11 20:17 | 显示全部楼层

正好需要这个资料,如果有SDK就更好了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表