久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 4721|回復(fù): 1
打印 上一主題 下一主題
收起左側(cè)

LPC2148像往U盤拷貝文件一樣更新用戶程序

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:102492 發(fā)表于 2017-11-11 17:34 | 只看該作者 |只看大圖 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
在網(wǎng)上爬行了很久才找到一個(gè)介紹USBMEM_BOOTLOADER的且有源代碼的論壇,用KEIL 編譯后結(jié)果不能運(yùn)行,后來才找到問題的根源:
//usbhw.c
void USB_Init (void) {
  PINSEL1 &= ~0xC000C000;
//PINSEL1 |=  0x40004000;  //這是原來的程序
  PINSEL1 |=  0x80004000;     /* Select USB Link, VBUS */

原來得改一下才能用到我的板子上面。

另外,原來的程序是在復(fù)位時(shí)檢測P0.15是否為低來判斷是進(jìn)入用戶程序,還是USB IAP程序,我針對我的板子改了一下,我用了兩個(gè)按鈕來控制它,當(dāng)按下P0.21的按鈕時(shí)運(yùn)行用戶程序,當(dāng)按下P0.22的按鈕時(shí)則運(yùn)行USB IAP程序:

首先要在sbl_config.h中做一下修改:

#define USER_START_SECTOR 2   //用戶程序起始扇區(qū)
#define MAX_USER_SECTOR 26    //最大扇區(qū)    LPC2146是 14,LPC2148是26

#define ISP_ENTRY_GPIO_REG 0xE0028000                  /* Port */
#define ISP_ENTRY_PIN21            21          /* User Code Pin  */ //這里原來是 15
#define ISP_ENTRY_PIN22            22          /* USB IAP Pin  */  //這個(gè)是增加的

然后把sbl_iap.c里面的相關(guān)內(nèi)容修改一下:

void check_isp_entry_pin(void)
{
while(1)
  {
    if(!( (*(volatile unsigned *)ISP_ENTRY_GPIO_REG) & (0x1<<isp_entry_pin21)) )[="" size][="" font][="" backcolor][="" color]
        {
            execute_user_code(); break;
        }
        if(!( (*(volatile unsigned *)ISP_ENTRY_GPIO_REG) & (0x1<<isp_entry_pin22)) )[="" size][="" font][="" backcolor][="" color]
        {
         break;   // Enter ISP mode
        }
  }
}

現(xiàn)在就可以來實(shí)驗(yàn)一下了:

usbmem程序的設(shè)置
boot程序按照這個(gè)設(shè)置編譯程序,要輸出HEX文件,然后試用ISP工具將其下載到LPC2148中。
現(xiàn)在按一下復(fù)位按鈕,按K1(P0.21)沒有反應(yīng),因?yàn)楝F(xiàn)在還沒有用戶程序;按一下K2(P0.22),指示燈亮了,此時(shí)電腦會(huì)顯示發(fā)現(xiàn)了新硬件:

電腦中出現(xiàn)了一個(gè)可移動(dòng)磁盤
打開這個(gè)磁盤,會(huì)發(fā)現(xiàn)里面有一個(gè)文件是492K,

得把這個(gè)文件刪除掉才能拷貝入你自己的程序
然后再編譯用戶程序,要把起始位置修改為0x2000;同時(shí)要輸出BIN文件:(在user  run  寫入fromelf --bin .FlashBlinky.axf -o .FlashBlinky.bin)把得到的BIN文件拷貝入空白的磁盤:

拷入用戶程序
按一下復(fù)位鍵,再按一下K1,就開始運(yùn)行流水燈程序了。

單片機(jī)源程序如下:
  1. /*----------------------------------------------------------------------------
  2. *      U S B  -  K e r n e l
  3. *----------------------------------------------------------------------------
  4. *      Name:    USBUSER.C
  5. *      Purpose: USB Custom User Module
  6. *      Version: V1.10
  7. *----------------------------------------------------------------------------
  8. *      This software is supplied "AS IS" without any warranties, express,
  9. *      implied or statutory, including but not limited to the implied
  10. *      warranties of fitness for purpose, satisfactory quality and
  11. *      noninfringement. Keil extends you a royalty-free right to reproduce
  12. *      and distribute executable files created using this software for use
  13. *      on Philips LPC2xxx microcontroller devices only. Nothing else gives
  14. *      you the right to use this software.
  15. *
  16. *      Copyright (c) 2005-2006 Keil Software.
  17. *---------------------------------------------------------------------------*/

  18. #include <LPC214X.H>                        /* LPC214x definitions */

  19. #include "type.h"

  20. #include "usb.h"
  21. #include "usbcfg.h"
  22. #include "usbhw.h"
  23. #include "usbcore.h"
  24. #include "usbuser.h"
  25. #include "mscuser.h"

  26. #include "memory.h"


  27. /*
  28. *  USB Power Event Callback
  29. *   Called automatically on USB Power Event
  30. *    Parameter:       power: On(TRUE)/Off(FALSE)
  31. */

  32. #if USB_POWER_EVENT
  33. void USB_Power_Event (BOOL  power) {
  34. }
  35. #endif


  36. /*
  37. *  USB Reset Event Callback
  38. *   Called automatically on USB Reset Event
  39. */

  40. #if USB_RESET_EVENT
  41. void USB_Reset_Event (void) {
  42.   USB_ResetCore();
  43.   IOCLR1 = LED_CFG;                         /* Turn Off Cfg LED */
  44. }
  45. #endif


  46. /*
  47. *  USB Suspend Event Callback
  48. *   Called automatically on USB Suspend Event
  49. */

  50. #if USB_SUSPEND_EVENT
  51. void USB_Suspend_Event (void) {
  52.   IOSET1 = LED_SUSP;                        /* Turn On Suspend LED */
  53. }
  54. #endif


  55. /*
  56. *  USB Resume Event Callback
  57. *   Called automatically on USB Resume Event
  58. */

  59. #if USB_RESUME_EVENT
  60. void USB_Resume_Event (void) {
  61.   IOCLR1 = LED_SUSP;                        /* Turn Off Suspend LED */
  62. }
  63. #endif


  64. /*
  65. *  USB Remote Wakeup Event Callback
  66. *   Called automatically on USB Remote Wakeup Event
  67. */

  68. #if USB_WAKEUP_EVENT
  69. void USB_WakeUp_Event (void) {
  70. }
  71. #endif


  72. /*
  73. *  USB Start of Frame Event Callback
  74. *   Called automatically on USB Start of Frame Event
  75. */

  76. #if USB_SOF_EVENT
  77. void USB_SOF_Event (void) {
  78. }
  79. #endif


  80. /*
  81. *  USB Error Event Callback
  82. *   Called automatically on USB Error Event
  83. *    Parameter:       error: Error Code
  84. */

  85. #if USB_ERROR_EVENT
  86. void USB_Error_Event (DWORD error) {
  87. }
  88. #endif


  89. /*
  90. *  USB Set Configuration Event Callback
  91. *   Called automatically on USB Set Configuration Request
  92. */

  93. #if USB_CONFIGURE_EVENT
  94. void USB_Configure_Event (void) {

  95.   if (USB_Configuration) {                  /* Check if USB is configured */
  96.     IOSET1 = LED_CFG;                       /* Turn On Cfg LED */
  97.   } else {
  98.     IOCLR1 = LED_CFG;                       /* Turn Off Cfg LED */
  99.   }
  100. }
  101. #endif


  102. /*
  103. *  USB Set Interface Event Callback
  104. *   Called automatically on USB Set Interface Request
  105. */

  106. #if USB_INTERFACE_EVENT
  107. void USB_Interface_Event (void) {
  108. }
  109. #endif


  110. /*
  111. *  USB Set/Clear Feature Event Callback
  112. *   Called automatically on USB Set/Clear Feature Request
  113. */

  114. #if USB_FEATURE_EVENT
  115. void USB_Feature_Event (void) {
  116. }
  117. #endif


  118. #define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : NULL)

  119. /* USB Endpoint Events Callback Pointers */
  120. void (* const USB_P_EP[16]) (DWORD event) = {
  121.   P_EP(0),
  122.   P_EP(1),
  123.   P_EP(2),
  124.   P_EP(3),
  125.   P_EP(4),
  126.   P_EP(5),
  127.   P_EP(6),
  128.   P_EP(7),
  129.   P_EP(8),
  130.   P_EP(9),
  131.   P_EP(10),
  132.   P_EP(11),
  133.   P_EP(12),
  134.   P_EP(13),
  135.   P_EP(14),
  136.   P_EP(15),
  137. };


  138. /*
  139. *  USB Endpoint 1 Event Callback
  140. *   Called automatically on USB Endpoint 1 Event
  141. *    Parameter:       event
  142. */

  143. void USB_EndPoint1 (DWORD event) {
  144. }


  145. /*
  146. *  USB Endpoint 2 Event Callback
  147. *   Called automatically on USB Endpoint 2 Event
  148. *    Parameter:       event
  149. */

  150. void USB_EndPoint2 (DWORD event) {

  151.   switch (event) {
  152.     case USB_EVT_OUT:
  153.       MSC_BulkOut();
  154.       break;
  155.     case USB_EVT_IN:
  156.       MSC_BulkIn();
  157.       break;
  158.   }
  159. }


  160. /*
  161. *  USB Endpoint 3 Event Callback
  162. *   Called automatically on USB Endpoint 3 Event
  163. *    Parameter:       event
  164. */

  165. void USB_EndPoint3 (DWORD event) {
  166. }


  167. /*
  168. *  USB Endpoint 4 Event Callback
  169. *   Called automatically on USB Endpoint 4 Event
  170. *    Parameter:       event
  171. */

  172. void USB_EndPoint4 (DWORD event) {
  173. }


  174. /*
  175. *  USB Endpoint 5 Event Callback
  176. *   Called automatically on USB Endpoint 5 Event
  177. *    Parameter:       event
  178. */

  179. void USB_EndPoint5 (DWORD event) {
  180. }


  181. /*
  182. *  USB Endpoint 6 Event Callback
  183. *   Called automatically on USB Endpoint 6 Event
  184. *    Parameter:       event
  185. */

  186. void USB_EndPoint6 (DWORD event) {
  187. }


  188. /*
  189. *  USB Endpoint 7 Event Callback
  190. *   Called automatically on USB Endpoint 7 Event
  191. *    Parameter:       event
  192. */

  193. void USB_EndPoint7 (DWORD event) {
  194. }


  195. /*
  196. *  USB Endpoint 8 Event Callback
  197. *   Called automatically on USB Endpoint 8 Event
  198. *    Parameter:       event
  199. */

  200. void USB_EndPoint8 (DWORD event) {
  201. }


  202. /*
  203. *  USB Endpoint 9 Event Callback
  204. *   Called automatically on USB Endpoint 9 Event
  205. *    Parameter:       event
  206. */

  207. void USB_EndPoint9 (DWORD event) {
  208. }


  209. /*
  210. *  USB Endpoint 10 Event Callback
  211. *   Called automatically on USB Endpoint 10 Event
  212. *    Parameter:       event
  213. */

  214. void USB_EndPoint10 (DWORD event) {
  215. }


  216. /*
  217. *  USB Endpoint 11 Event Callback
  218. *   Called automatically on USB Endpoint 11 Event
  219. *    Parameter:       event
  220. */

  221. void USB_EndPoint11 (DWORD event) {
  222. }


  223. /*
  224. *  USB Endpoint 12 Event Callback
  225. *   Called automatically on USB Endpoint 12 Event
  226. ……………………

  227. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復(fù)制代碼


所有資料51hei提供下載:
USB IAP 程序.rar (427.99 KB, 下載次數(shù): 18)


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏2 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:574696 發(fā)表于 2019-6-29 18:29 | 只看該作者
您好,LPC2148的IAP程序編譯不通過。請求幫助。QQ:810001560
回復(fù)

使用道具 舉報(bào)

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 精品成人av| 在线中文字幕日韩 | 国产精品成人一区二区三区 | av天空| 欧美性成人 | 亚洲黄色一区二区三区 | 国产福利免费视频 | 在线精品亚洲欧美日韩国产 | 一区二区三区四区视频 | 蜜桃视频在线观看免费视频网站www | 国产精品久久久久一区二区三区 | 日日拍夜夜 | 久久久久九九九女人毛片 | 国产一区二区三区四区五区加勒比 | 日韩中文字幕在线视频 | 国产日韩欧美激情 | 日本成人片在线观看 | 无码一区二区三区视频 | 四虎影院在线观看av | 亚洲视频中文 | 视频在线一区二区 | 免费成人午夜 | www国产亚洲精品久久网站 | 免费成人高清 | 亚洲国产精品久久久久 | 日日操操| 欧日韩不卡在线视频 | 国产精品免费一区二区三区四区 | 美女久久久久久久 | 国产aa| 久久9热| 五月婷婷在线播放 | 中文字幕视频一区二区 | 国产激情91久久精品导航 | 日本韩国欧美在线观看 | 四虎影院新地址 | 先锋影音资源网站 | 二区精品 | 日韩一二三区 | 亚洲人成人一区二区在线观看 | 欧美日韩视频在线播放 |