OSAL代码分析.docx

上传人:b****5 文档编号:3434888 上传时间:2022-11-23 格式:DOCX 页数:161 大小:64.34KB
下载 相关 举报
OSAL代码分析.docx_第1页
第1页 / 共161页
OSAL代码分析.docx_第2页
第2页 / 共161页
OSAL代码分析.docx_第3页
第3页 / 共161页
OSAL代码分析.docx_第4页
第4页 / 共161页
OSAL代码分析.docx_第5页
第5页 / 共161页
点击查看更多>>
下载资源
资源描述

OSAL代码分析.docx

《OSAL代码分析.docx》由会员分享,可在线阅读,更多相关《OSAL代码分析.docx(161页珍藏版)》请在冰豆网上搜索。

OSAL代码分析.docx

OSAL代码分析

目录

AccessCodeSpace.s512

flashDmaTrigger.s512

flashErasePage.s513

OSAL.h4

OSAL.c7

OSAL_CUSTOM_H18

OSAL_Memory.h19

OSAL_Memory.c21

OSAL_Nv.h27

OSAL_Nv.C28

OSAL_PwrMgr.h45

OSAL_PwrMgr.c46

OSAL_Tasks.h48

OSAL_Tasks.c50

OSAL_Timers.h52

OSAL_Timers.c54

ZComDef.h62

 

AccessCodeSpace.s51

NAMECC2430_READ_ANY_CODE_BYTE

;Copyright(c)2006byTexasInstruments,Inc.

;AllRightsReserved.Permissiontouse,reproduce,copy,prepare

;derivativeworks,modify,distribute,perform,displayorsellthis

;softwareand/oritsdocumentationforanypurposeisprohibited

;withouttheexpresswrittenconsentofTexasInstruments,Inc.

MEMCTREQU0xC7

RSEGNEAR_CODE

PUBLICGetCodeByte

FUNCTIONGetCodeByte,0203H

;

;Getabytefromcodespace.

;

;uint8GetCodeByte(uint32logical_address)

;

;Input:

the"logicaladdress"isjusttheoffsetofthe

;byteassumingacontiguousflataddressspace.

;

;Returns:

BytereadreturnedinR1

;

;***********************************

;***Functionisa__near_func***

;***********************************

;

;firstwehavetomapthelogicaladdresstothelinkeraddress.then

;wecanpopulatetheMEMCTRregisterproperly.

;

;logicaladrlinkeradrBank

;0x00000-0x07FFF->0x00000-0x07FFF0

;0x08000-0x08FFF->0x18000-0x1FFFF1

;0x10000-0x17FFF->0x28000-0x2FFFF2

;0x18000-0x1FFFF->0x38000-0x3FFFF3

;

;thelogicaladdressisinR5:

R4:

R3:

R2(MSB-LSB)butR5shouldalwaysbe0.

;

;wecantellthebankbyshiftingtheentireaddressleft1.afterthat

;thethirdbyte(R4)willcontainthebanknumber(0-3).awkwardness

;comesinwhensettingtheDPTR.Oncethelogicaladdressis>0x7FFF

;thelinkeraddressisalwaysbeginsat0xb8000where'b'isthebank

;number.

;

;

GetCodeByte:

;getthebanknumber

MOVA,R4;arewepast64K?

RLA;shiftthebit(ifit'sthere)left

MOVB,A;savetheshiftedresultinB

MOVA,R3;nowwewanttoshiftintheMSBinr3tocompletethebanknumber

ANLA,#0x80;maskofftheMSB

RLA;shiftitintothelsbposition.

ORLA,B;ORbit0inAwithBtocompletethebanknumber

SWAPA;swaptogetthebanknumberintothecorrectplaceforMEMCTR

MOVB,A;saveitinB

;here'stheawkwardpart.ifthebankis2wehavetoadd

;0x80toR3.

XRLA,#0x20;Astillhasthenibble-swappedbanknumber.ifthisresaultis0itwas2.

JNZ_notBank2

MOVA,R3;it'sBank2.weneedtomodifyR3forlateruseinDPH

ORLA,#0x80

MOVR3,A

;prepareMEMCTRandDPTR

_notBank2:

MOVA,MEMCTR;getcurrentMEMCTR

MOVR4,A;saveit

ANLA,#0xCF;maskoffbankbits

ORLA,B;ORintherequiredbanknumber

MOVMEMCTR,A;savetheresulttoMEMCTR

CLRA;getready...

MOVDPH,R3

MOVDPL,R2

MOVCA,@A+DPTR;getbyte

MOVR1,A;movebytetoreturnregister

MOVMEMCTR,R4;restoreMEMCTR

RET

 

END

flashDmaTrigger.s51

/******************************************************************************

*

*Filename:

flashDmaTrigger.s51

*Target:

cc2430

*Author:

KJA

*Revised:

10/3-2006

*Revision:

1.0

*

*Copyright(c)2006byTexasInstruments,Inc.

*AllRightsReserved.Permissiontouse,reproduce,copy,prepare

*derivativeworks,modify,distribute,perform,displayorsellthis

*softwareand/oritsdocumentationforanypurposeisprohibited

*withouttheexpresswrittenconsentofTexasInstruments,Inc.

*

******************************************************************************/

;;-----------------------------------------------------------------------------

;;Thisfunctionwrite0x02toFCTL,thereasonfordoing

;;thisinassemblyisthattheinstructionmostbealigned

;;to4.

;;Thealigmentisdonewith"RSEGRCODE

(2)"

;;-----------------------------------------------------------------------------

#include"ioCC2430.h"

MODULEflashDmaTrigger.s51

RSEGRCODE

(2)

PUBLIChalFlashDmaTrigger

FUNCTIONhalFlashDmaTrigger,0203H

halFlashDmaTrigger:

ORLFCTL,#0x02;

RET;

END;

flashErasePage.s51

/******************************************************************************

*

*Filename:

flashErasePage.s51

*Target:

cc2430

*Author:

EFU

*Revised:

13/12-2005

*Revision:

1.0

*

*Copyright(c)2006byTexasInstruments,Inc.

*AllRightsReserved.Permissiontouse,reproduce,copy,prepare

*derivativeworks,modify,distribute,perform,displayorsellthis

*softwareand/oritsdocumentationforanypurposeisprohibited

*withouttheexpresswrittenconsentofTexasInstruments,Inc.

*

******************************************************************************/

;;------------------------------------------------------------------------------------------------------

;;Seehal.hforadescriptionofthisfunction.

;;------------------------------------------------------------------------------------------------------

#include"ioCC2430.h"

 

MODULEflashErasePage.s51

RSEGRCODE

PUBLICflashErasePage

FUNCTIONflashErasePage,0203H

DS1

flashErasePage:

;R2(LSB)andR3(MSB)containsthestartaddressofthebufferfromwhichtheprogramcanberuninRAM

;R1containstheflashpagethedataistobewrittento

;Makesurethatinterruptsareoff

MOVR0,#01;

JBCEA,intsOffHere;

MOVR0,#00;

intsOffHere:

;Storingtheinitialdatapointerselect.

PUSHDPH;

PUSHDPL;

PUSHDPH1;

PUSHDPL1;

PUSHDPS;

;SetDPTR0=addressinXDATARAMtowhichtheflashwriteprocedurewhichistobecopied.

MOVA,R3;

MOVDPH,A;

MOVA,R2;

MOVDPL,A;

;SavingthestartaddressoftheactualflashwriteprocedureinXDATARAM.

PUSHDPL;

PUSHDPH;

;SetDPTR1=startaddressoftheproceduretemplateinCODE

;ThisprocedureistobecopiedtoXDATA.

MOVDPH1,#HIGH(eraseFlashProcStart);

MOVDPL1,#LOW(eraseFlashProcStart);

;UseR1tocountloops...

MOVR4,#eraseFlashProcEnd-eraseFlashProcStart;

;Copy@DPTR1->@DPTR0

copyLoop:

MOVDPS,#1;

MOVXA,@DPTR;

INCDPTR;

MOVDPS,#0;

MOVX@DPTR,A;

INCDPTR;

DJNZR4,copyLoop;

 

;Settingtheflashpagetowriteto

;Bits6:

1ofFADDRHindicateswhichpagetowriteto.

MOVA,R1

RLA

MOVFADDRH,A

MOVFADDRL,#00H

;SettingtheflashwritetimingaccordingtotheclockdivisionfactorinCLKCON.

MOVA,CLKCON

ANLA,#07H

MOVR4,A

INCR4

MOVA,#054H

rotate:

CLRC

RRCA

DJNZR4,rotate

MOVFWT,A

;Datapointer0indicateswherethestartofthecopiedroutineinXDATAislocated.

;Pointertostartofdatatocopyisindatapointer1.

MOVDPS,#0;

POPDPH;

POPDPL;

PUSHMEMCTR;

MOVMEMCTR,#051H;

;Maketheindirectfunctioncall

LCALLindirCall;

POPMEMCTR;

;Usingtheoriginaldatapointer

POPDPS;

POPDPL1;

POPDPH1;

POPDPL;

POPDPH;

MOVA,R0;

JZintsWereOff;

SETBEA;

intsWereOff:

RET;

 

;CallingtheflashwriteinXDATARAM.(PointedtobyDPTR0)

indirCall:

CLRA;

JMP@A+DPTR;

 

eraseFlashProcStart:

;Erasingthepage

MOVFCTL,#01H

waitEraseLoop:

MOVA,FCTL

ANLA,#80H

JNZwaitEraseLoop

 

done:

RET;

eraseFlashProcEnd:

END;

OSAL.h

#ifndefOSAL_H

#defineOSAL_H

/*********************************************************************

Filename:

OSAL.h

Revised:

$Date:

2006-09-2918:

09:

20-0700(Fri,29Sep2006)$

Revision:

$Revision:

12162$

Description:

ThisAPIallowsthesoftwarecomponentsintheZ-stacktobe

writtenindependentlyofthespecificsoftheoperatingsystem,

kernelortaskingenvironment(includingcontrolloopsor

connect-to-interruptsystems).

Notes:

Copyright(c)2006byTexasInstruments,Inc.

AllRightsReserved.Permissiontouse,reproduce,copy,prepare

derivativeworks,modify,distribute,perform,displayorsellthis

softwareand/oritsdocumentationforanypurposeisprohibited

withouttheexpresswrittenconsentofTexasInstruments,Inc.

*********************************************************************/

#ifdef__cplusplus

extern"C"

{

#endif

/*********************************************************************

*INCLUDES

*/

#include"ZComDef.h"

#include"OSAL_Memory.h"

#include"OSAL_Timers.h"

/*********************************************************************

*MACROS

*/

#defineosal_offsetof(type,member)((uint16)&(((type*)0)->member))

#defineOSAL_MSG_NEXT(msg_ptr)((osal_msg_hdr_t*)(msg_ptr)-1)->next

#defineOSAL_MSG_Q_INIT(q_ptr)*(q_ptr)=NULL

#defineOSAL_MSG_Q_EMPTY(q_ptr)(*(q_ptr)==NULL)

#defineOSAL_MSG_Q_HEAD(q_ptr)(*(q_ptr))

/*********************************************************************

*CONSTANTS

*/

/***Interrupts***/

#defineINTS_ALL0xFF

 

/*********************************************************************

*TYPEDEFS

*/

typedefstruct

{

void*next;

uint16len;

bytedest_id;

}osal_msg_hdr_t;

typedefstruct

{

uint8event;

uint8status;

}osal_event_hdr_t;

typedefvoid*osal_msg_q_t;

/*********************************************************************

*GLOBALVARIABLES

*/

/*********************************************************************

*FUNCTIONS

*/

/***MessageManagement***/

/*

*TaskMessageAllocation

*/

externbyte*osal_msg_allocate(uint16len);

/*

*TaskMessageDeallocation

*/

externbyteosal_msg_deallocate(byte*msg_ptr);

/*

*TaskMessagesCount

*/

externUINT16osal_num_msgs(void);

/*

*SendaTaskMessage

*/

externbyteosal_msg_send(bytedestination_task,byte*msg_ptr);

/*

*ReceiveaTaskMessage

*/

externbyte*osal_msg_receive(bytetask_id);

 

/*

*EnqueueaTaskMessage

*/

externvoidosal_msg_enqueue(osal_msg_q_t*q_ptr,void*msg_ptr);

/*

*EnqueueaTaskMessageUptoMax

*/

externbyteosal_msg_enqueue_max(osal_msg_q_t*q_p

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 人力资源管理

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

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