SPIdriverIMPLv01.docx

上传人:b****6 文档编号:12852122 上传时间:2023-06-08 格式:DOCX 页数:12 大小:131.61KB
下载 相关 举报
SPIdriverIMPLv01.docx_第1页
第1页 / 共12页
SPIdriverIMPLv01.docx_第2页
第2页 / 共12页
SPIdriverIMPLv01.docx_第3页
第3页 / 共12页
SPIdriverIMPLv01.docx_第4页
第4页 / 共12页
SPIdriverIMPLv01.docx_第5页
第5页 / 共12页
SPIdriverIMPLv01.docx_第6页
第6页 / 共12页
SPIdriverIMPLv01.docx_第7页
第7页 / 共12页
SPIdriverIMPLv01.docx_第8页
第8页 / 共12页
SPIdriverIMPLv01.docx_第9页
第9页 / 共12页
SPIdriverIMPLv01.docx_第10页
第10页 / 共12页
SPIdriverIMPLv01.docx_第11页
第11页 / 共12页
SPIdriverIMPLv01.docx_第12页
第12页 / 共12页
亲,该文档总共12页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

SPIdriverIMPLv01.docx

《SPIdriverIMPLv01.docx》由会员分享,可在线阅读,更多相关《SPIdriverIMPLv01.docx(12页珍藏版)》请在冰点文库上搜索。

SPIdriverIMPLv01.docx

SPIdriverIMPLv01

SPIDriverImplementation

TianjinUniversity—InfineonAutomotiveElectronicJointLaboratory

StateKeyLaboratoryofEngines

TianJinUniversity,China

 

Revisionhistory

Version

By

Modifications

V0.1,10thSep2007

NenghuiZhou

Creation

V0.117thNovember2008

Changedocumentnameto

Contents

1Introduction4

1.1Overview4

1.2Reference4

2.Typedefinition5

3GlobalVariable6

4FunctionDefinitions7

4.1OCSPI_InitSync7

4.2OCSPI_DeInitSync8

4.3OCSPI_ReadAsync9

4.4OCSPI_WriteAsync11

4.5OCSPI_SuspendAsync13

4.6OCSPI_Notification14

4.7OCSPIInterruptFunctions.15

5ResourcesConfiguration17

5.1PeriperalConfig17

5.2InterruptConfig17

6CompileEnvironment18

1Introduction

1.1Overview

ThisdocumentdescribestheimplementationsoftheSPIdrivertobedevelopedintheframeoftheGEMS-K1project.

TheSPIdriverconfiguresthemicrocontrollerinternalperipherals,sothattransmissionandreceptionofdataispossibleusingserialsynchronouscommunication.Themicrocontrolleractsasthemasterofthecommunication,anditisconnectedtoseveralslavedevices.

 

Note:

1.Thisdriverisspecifiedformastermodeonly.

2.AchannelisaSWlogicalentitywhichismappedtoahardwarechipselectsignal.

3.Errors(Transmit,Receive,phaseandbaudrate)arenothandledbythedriver.

1.2Reference

[1]SPIdriverspecificationdocument

[2]TC1766_um_v1.1_2005_08.pdfdocument

2.Typedefinition

Type

Description

Range

OCSPI_ErrorType

Recommendedtype:

16bitunsignedvalue.Numbersfrom0to15arereservedfortheHISIOLibraryitself,numbersbetween16and63aredefinedintheHISIODriverdocument.Errorcodesfrom64to127arefordriverspecificerrorcodesnotdefinedintheHISIODriverdocumentandnumbersstartingfrom128arereservedforfutureuse.

OCSPI_R_OK

OCSPI_R_BUSY

OCSPI_R_INVALID_CHANNEL

OCSPI_ChannelType

Typetospecifyachannelfromachanneldevices.Fixtype:

16bitunsignedvalue.

[0,7]

OCSPI_MemPtrType

Typetoholdtheaddresstoamemorylocation.

0x00000000to0xFFFFFFFF

OCSPI_SizeType

Typetoholdinfoaboutthesizeofanobject.

0x0000to0xFFFF

OCSPI_NotifType

16bitunsignedvalue.

OCSPI_N_READY

OCSPI_N_SUSPENDED

3GlobalVariable

Thischapterdescribestheglobalvariableusedbyscheduler.

Varialbes

Type

Description

SPI_MODULE_STATUS

OCSPI_NotifType

SPImodulestatus:

busyoridle

SPI_MODULE_READ_ADDRESS

OCSPI_MemPtrType

Readdatastartingfrom“address”

SPI_MODULE_WRITE_ADDRESS

OCSPI_MemPtrType

Writedatastartingfrom“address”

SPI_MODULE_MODE

OCSPI_NotifType

SPImodule:

readorwrite

SPI_MODULE_SIZE

OCSPI_NotifType

thenumberofwordstobereceivedortransimit.

SPI_MODULE_PLAYLOAD

OCSPI_SizeType

thenumberofSPIreceivedwords

SPI_MODULE_CHANNEL

OCSPI_ChannelType

SPIcurrentchannel

4FunctionDefinitions

4.1OCSPI_InitSync

Syntax

OCSPI_ErrorTypeOCSPI_InitSync(void)

Parameters

none

Return

OCSPI_R_OK:

initializationwassuccessful.

Notification

Description

Initializesglobalandmoduleconfiguration.Indetailsthedrivershould:

∙Enablemoduleclock.

∙ForMRST:

SelectoptionAorB(ifavailable),selectalternateinputmodeandpulldevice.

∙ForSCLK,MTSRandusedchipselect:

SelectoptionAorB(ifavailable),alternateoutputmodeanddriverstrength.

∙Setactivechannelsinvalid.

∙Receiveinterrupt:

disableSRN(SRE=0),clearinterruptrequestflag(CLRR=1)andsetpriority.

Reentrancy

No

Remarks

 

4.2

OCSPI_DeInitSync

Syntax

OCSPI_ErrorTypeOCSPI_DeInitSync(void)

Parameters

None

Return

OCSPI_R_OK:

de-initializationwassuccessful.

Notification

Description

ResetsallSPIregisters.

Reentrancy

No

Remarks

4.3

OCSPI_ReadAsync

Syntax

OCSPI_ErrorTypeOCSPI_ReadAsync(OCSPI_ChannelTypechannel,OCSPI_MemPtrTypeaddress,OCSPI_SizeTypesize)

Parameters

channel:

the16bitchannelidentificationnumber

address:

theaddresswherethereceiveddataiswritten

size:

specifiesthenumberofwordstobereceived.

Return

OCSPI_R_OK:

Readingofmessageissuccessful.

OCSPI_R_BUSY:

SPIbusnotidle.

OCSPI_R_INVALID_CHANNEL:

notconfiguredchannelhasbeencalled.

Notification

OCSPI_N_READY,OCSPI_N_SUSPENDED

Description

Thefunctionallowsthereceptionof“size”words,whicharetobestoredstartingfrom“address”.

IftheSPIbusisnotidle,thefunctionreturnswithOCSPI_R_BUSY.

WhenallwordshavebeenreceivedthenotificationfunctioniscalledwithOCSPI_N_READY.

TobeabletohandlethetransferasynchronouslytheSPIwillswitchontherequiredinterrupts.Theywillbeswitchedoffwhenallwordshavebeenreceivedorwhenthechannelissuspended.

Reentrancy

No

Remarks

TheSPItransmitsdummydatatoreceivethewanteddata.

 

 

4.4

OCSPI_WriteAsync

Syntax

OCSPI_ErrorTypeOCSPI_WriteAsync(OCSPI_ChannelTypechannel,OCSPI_MemPtrTypeaddress,OCSPI_SizeTypesize)

Parameters

channel:

the16bitchannelidentificationnumber

address:

theaddresswiththewordstowrite

size:

specifiesthenumberofwordstobereceived.

Return

OCSPI_R_OK:

Readingofmessageissuccessful.

OCSPI_R_BUSY:

SPIbusnotidle.

OCSPI_R_INVALID_CHANNEL:

notconfiguredchannelhasbeencalled.

Notification

OCSPI_N_READY,OCSPI_N_SUSPENDED

Description

Thefunctionallowsthetransmissionof“size”words,whicharestoredstartingfrom“address”.

IftheSPIbusisnotidle,thefunctionreturnswithOCSPI_R_BUSY.

WhenallwordshavebeentransmittedthenotificationfunctioniscalledwithOCSPI_N_READY.

TobeabletohandlethetransferasynchronouslytheSPIwillswitchontherequiredinterrupts.Theywillbeswitchedoffwhenallwordshavebeenreceivedorwhenthechannelissuspended.

Reentrancy

No

Remarks

 

 

4.5

OCSPI_SuspendAsync

Syntax

OCSPI_ErrorTypeOCSPI_SuspendAsync(OCSPI_ChannelTypechannel)

Parameters

channel:

the16bitchannelidentificationnumber

Return

OCSPI_R_OK:

functionexecuted

OCSPI_R_INVALID_CHANNEL:

notconfiguredchannelhasbeencalled.

Notification

OCSPI_N_SUSPENDED

Description

SuspendsanyasynchronoustransferontheSPIbus.

Reentrancy

Yes

Remarks

 

 

4.6

OCSPI_Notification

Syntax

voidOCSPI_Notification(OCSPI_ChannelTypechannel,OCSPI_NotifTypenotifType,OCSPI_SizeTypesize)

Parameters

channel:

the16bitchannelidentificationnumber

notifType:

OCSPI_N_READY,OCSPI_N_SUSPENDED

size:

numberofwordsthathavebeentransmitted/received

Return

Notification

Description

Thisisthefunctionprototypeforthenotificationcallbackfunction.TheimplementationisTBD.

Reentrancy

Yes

Remarks

4.7

OCSPIInterruptFunctions.

4.7.1ReceiveInterrupt

4.7.2ConfigureChannel

 

4.7.3CheckInit

 

5ResourcesConfiguration

TheresourceusedbySPIdriver

5.1PeriperalConfig

Source

Description

SSC0

AsSPIhardwareinterface

SLSO[7:

0]

Slaveselectionoutputs

5.2InterruptConfig

Source

SRN

TOS

Priority

Name

Description

SSC0

SSC0_RSRC

CPU

3

SSC0_viRx

Disposereceiveaffairs

6CompileEnvironment

CompileTool:

TaskingforTricore

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

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2