ImageVerifierCode 换一换
格式:DOCX , 页数:161 ,大小:64.34KB ,
资源ID:3434888      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/3434888.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(OSAL代码分析.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

OSAL代码分析.docx

1、OSAL代码分析目录AccessCodeSpace.s51 2flashDmaTrigger.s51 2flashErasePage.s51 3OSAL.h 4OSAL.c 7OSAL_CUSTOM_H 18OSAL_Memory.h 19OSAL_Memory.c 21OSAL_Nv.h 27OSAL_Nv.C 28OSAL_PwrMgr.h 45OSAL_PwrMgr.c 46OSAL_Tasks.h 48OSAL_Tasks.c 50OSAL_Timers.h 52OSAL_Timers.c 54ZComDef.h 62AccessCodeSpace.s51 NAME CC2430_RE

2、AD_ANY_CODE_BYTE ; Copyright (c) 2006 by Texas Instruments, Inc. ; All Rights Reserved. Permission to use, reproduce, copy, prepare ; derivative works, modify, distribute, perform, display or sell this ; software and/or its documentation for any purpose is prohibited ; without the express written co

3、nsent of Texas Instruments, Inc.MEMCTR EQU 0xC7 RSEG NEAR_CODE PUBLIC GetCodeByte FUNCTION GetCodeByte, 0203H ; ; Get a byte from code space. ; ; uint8 GetCodeByte(uint32 logical_address) ; ; Input: the logical address is just the offset of the ; byte assuming a contiguous flat address space. ; ; Re

4、turns: Byte read returned in R1 ; ; * ; * Function is a _near_func * ; * ; ; first we have to map the logical address to the linker address. then ; we can populate the MEMCTR register properly. ; ; logical adr linker adr Bank ; 0x00000-0x07FFF - 0x00000-0x07FFF 0 ; 0x08000-0x08FFF - 0x18000-0x1FFFF

5、1 ; 0x10000-0x17FFF - 0x28000-0x2FFFF 2 ; 0x18000-0x1FFFF - 0x38000-0x3FFFF 3 ; ; the logical address is in R5:R4:R3:R2 (MSB-LSB) but R5 should always be 0. ; ; we can tell the bank by shifting the entire address left 1. after that ; the third byte (R4) will contain the bank number (0-3). awkwardnes

6、s ; comes in when setting the DPTR. Once the logical address is 0x7FFF ; the linker address is always begins at 0xb8000 where b is the bank ; number. ; ;GetCodeByte: ; get the bank number MOV A,R4 ; are we past 64K? RL A ; shift the bit (if its there) left MOV B,A ; save the shifted result in B MOV

7、A,R3 ; now we want to shift in the MSB in r3 to complete the bank number ANL A,#0x80 ; mask off the MSB RL A ; shift it into the lsb position. ORL A,B ; OR bit 0 in A with B to complete the bank number SWAP A ; swap to get the bank number into the correct place for MEMCTR MOV B,A ; save it in B ; he

8、res the awkward part. if the bank is 2 we have to add ; 0x80 to R3. XRL A,#0x20 ; A still has the nibble-swapped bank number. if this resault is 0 it was 2. JNZ _notBank2 MOV A,R3 ; its Bank 2. we need to modify R3 for later use in DPH ORL A,#0x80 MOV R3,A ; prepare MEMCTR and DPTR_notBank2: MOV A,M

9、EMCTR ; get current MEMCTR MOV R4,A ; save it ANL A,#0xCF ; mask off bank bits ORL A,B ; OR in the required bank number MOV MEMCTR,A ; save the result to MEMCTR CLR A ; get ready. MOV DPH,R3 MOV DPL,R2 MOVC A,A+DPTR ; get byte MOV R1,A ; move byte to return register MOV MEMCTR,R4 ; restore MEMCTR RE

10、T ENDflashDmaTrigger.s51/* Filename: flashDmaTrigger.s51* Target: cc2430* Author: KJA* Revised: 10/3-2006* Revision: 1.0* Copyright (c) 2006 by Texas Instruments, Inc.* All Rights Reserved. Permission to use, reproduce, copy, prepare* derivative works, modify, distribute, perform, display or sell th

11、is* software and/or its documentation for any purpose is prohibited* without the express written consent of Texas Instruments, Inc.*/;-; This function write 0x02 to FCTL, the reason for doing; this in assembly is that the instruction most be aligned; to 4.; The aligment is done with RSEG RCODE (2);-

12、#include ioCC2430.h MODULE flashDmaTrigger.s51 RSEG RCODE (2) PUBLIC halFlashDmaTrigger FUNCTION halFlashDmaTrigger, 0203HhalFlashDmaTrigger: ORL FCTL, #0x02; RET; END;flashErasePage.s51/* Filename: flashErasePage.s51* Target: cc2430* Author: EFU* Revised: 13/12-2005* Revision: 1.0* Copyright (c) 20

13、06 by Texas Instruments, Inc.* All Rights Reserved. Permission to use, reproduce, copy, prepare* derivative works, modify, distribute, perform, display or sell this* software and/or its documentation for any purpose is prohibited* without the express written consent of Texas Instruments, Inc.*/;-; S

14、ee hal.h for a description of this function.;-#include ioCC2430.h MODULE flashErasePage.s51 RSEG RCODE PUBLIC flashErasePage FUNCTION flashErasePage, 0203H DS 1 flashErasePage: ; R2 (LSB) and R3 (MSB) contains the start address of the buffer from which the program can be run in RAM ; R1 contains the

15、 flash page the data is to be written to ; Make sure that interrupts are off MOV R0, #01; JBC EA, intsOffHere; MOV R0, #00;intsOffHere: ; Storing the initial data pointer select. PUSH DPH; PUSH DPL; PUSH DPH1; PUSH DPL1; PUSH DPS; ; Set DPTR0 = address in XDATA RAM to which the flash write procedure

16、 which is to be copied. MOV A, R3; MOV DPH, A; MOV A, R2; MOV DPL, A; ; Saving the start address of the actual flash write procedure in XDATA RAM. PUSH DPL; PUSH DPH; ; Set DPTR1 = start address of the procedure template in CODE ; This procedure is to be copied to XDATA. MOV DPH1, #HIGH(eraseFlashPr

17、ocStart); MOV DPL1, #LOW(eraseFlashProcStart); ; Use R1 to count loops. MOV R4, #eraseFlashProcEnd - eraseFlashProcStart; ; Copy DPTR1-DPTR0copyLoop: MOV DPS, #1; MOVX A, DPTR; INC DPTR; MOV DPS, #0; MOVX DPTR, A; INC DPTR; DJNZ R4, copyLoop; ; Setting the flash page to write to ; Bits 6:1 of FADDRH

18、 indicates which page to write to. MOV A,R1 RL A MOV FADDRH, A MOV FADDRL, #00H ; Setting the flash write timing according to the clock division factor in CLKCON. MOV A,CLKCON ANL A,#07H MOV R4,A INC R4 MOV A,#054Hrotate: CLR C RRC A DJNZ R4,rotate MOV FWT,A ; Data pointer 0 indicates where the star

19、t of the copied routine in XDATA is located. ; Pointer to start of data to copy is in data pointer 1. MOV DPS, #0; POP DPH; POP DPL; PUSH MEMCTR; MOV MEMCTR, #051H; ; Make the indirect function call LCALL indirCall; POP MEMCTR; ; Using the original data pointer POP DPS; POP DPL1; POP DPH1; POP DPL;

20、POP DPH; MOV A, R0; JZ intsWereOff; SETB EA;intsWereOff: RET; ; Calling the flash write in XDATA RAM. (Pointed to by DPTR0)indirCall: CLR A; JMP A+DPTR;eraseFlashProcStart: ; Erasing the page MOV FCTL, #01HwaitEraseLoop: MOV A, FCTL ANL A,#80H JNZ waitEraseLoopdone: RET;eraseFlashProcEnd: END;OSAL.h

21、#ifndef OSAL_H#define OSAL_H/* Filename: OSAL.h Revised: $Date: 2006-09-29 18:09:20 -0700 (Fri, 29 Sep 2006) $ Revision: $Revision: 12162 $ Description: This API allows the software components in the Z-stack to be written independently of the specifics of the operating system, kernel or tasking envi

22、ronment (including control loops or connect-to-interrupt systems). Notes: Copyright (c) 2006 by Texas Instruments, Inc. All Rights Reserved. Permission to use, reproduce, copy, prepare derivative works, modify, distribute, perform, display or sell this software and/or its documentation for any purpo

23、se is prohibited without the express written consent of Texas Instruments, Inc.*/#ifdef _cplusplusextern C#endif/* * INCLUDES */#include ZComDef.h#include OSAL_Memory.h#include OSAL_Timers.h/* * MACROS */#define osal_offsetof(type, member) (uint16) &(type *) 0)-member)#define OSAL_MSG_NEXT(msg_ptr)

24、(osal_msg_hdr_t *) (msg_ptr) - 1)-next#define OSAL_MSG_Q_INIT(q_ptr) *(q_ptr) = NULL#define OSAL_MSG_Q_EMPTY(q_ptr) (*(q_ptr) = NULL)#define OSAL_MSG_Q_HEAD(q_ptr) (*(q_ptr)/* * CONSTANTS */* Interrupts */#define INTS_ALL 0xFF/* * TYPEDEFS */typedef struct void *next; uint16 len; byte dest_id; osal_

25、msg_hdr_t;typedef struct uint8 event; uint8 status; osal_event_hdr_t;typedef void * osal_msg_q_t;/* * GLOBAL VARIABLES */* * FUNCTIONS */* Message Management */ /* * Task Message Allocation */ extern byte * osal_msg_allocate(uint16 len ); /* * Task Message Deallocation */ extern byte osal_msg_deallo

26、cate( byte *msg_ptr ); /* * Task Messages Count */ extern UINT16 osal_num_msgs( void ); /* * Send a Task Message */ extern byte osal_msg_send( byte destination_task, byte *msg_ptr ); /* * Receive a Task Message */ extern byte *osal_msg_receive( byte task_id ); /* * Enqueue a Task Message */ extern void osal_msg_enqueue( osal_msg_q_t *q_ptr, void *msg_ptr ); /* * Enqueue a Task Message Up to Max */ extern byte osal_msg_enqueue_max( osal_msg_q_t *q_p

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1