rainbowbs manual · rainbowbs(rbs) is an open-source base library developed for embedded systems...
TRANSCRIPT
![Page 2: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/2.jpg)
AcknowledgmentsThanksgoto:
DimitrivanHeesch,authorofDoxygen.AdamDunkels,authorofprotothreadslibraryandContikiOSkernel.NiuYuQingforlogoandsuggestions.Myfamilyforsupportingandencourage.Haroopad,awell-donemarkdowntool.Enyaforgreatvoicetolistentowhilecoding.
![Page 3: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/3.jpg)
AboutWhatisthismanualfor
ThismanualisusedasareferencetoRainbowBS(RBS)whichisanopen-sourcebaselibrarydevelopedforembeddedsystemsespeciallywithlimitresources.
![Page 4: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/4.jpg)
HowtogetsourcepackageRBShasbeencommittedtoGitHub.Soyoucangetthenewestsourcepackagefromhttps://github.com/jacobqwq/RainbowBS/
![Page 5: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/5.jpg)
FutureworkThisv0.1.0isthefirstdistributedRBSversion.
AlthoughRBScanbeusedindependently,itwillalsobecomeabasicpartofRainbowSysaccordingtotheplan.
ThegoalofRainbowSysistobuildanopen-sourceflexibleandconfigurablesystemsoftwarewrittenbyClanguageforembeddedsystems,especiallylikelowcostmicro-controllerswhichhavelimitresources.RainbowSyswillconsistofCMSIS-compatibleRTOS,filesystem,GUI,comunicationstack,etc....
SoRBSisthefirstdistributedcomponentofRainbowSysandwilloffercommonsupportfortheothercomponentsofRainbowSys.
ThenextdistributedcomponentofRainbowSyswillbetheGUIcomponentnamedRainbowGX(RGX),whichisnowbeingimprovedcontinuouslytogetherwithRBS.AndyouwillseeRGXsoon.:)
RGXDeskLevelDemonstration
![Page 6: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/6.jpg)
AuthorDesignedbyQWQcomingfromQingdao,ShandongProv,China.
Email:[email protected]
Generatedby 1.8.9.1
![Page 7: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/7.jpg)
TableofContents
WhatisRainbowBSRainbowBSFeaturesRequirementsLicenceConventions
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
Chapter1Introduction
![Page 8: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/8.jpg)
WhatisRainbowBSRainbowBS(RBS)isanopen-sourcebaselibrarydevelopedforembeddedsystemsespeciallywithlimitresources.
RBSiswrittenbyClanguageincompliancewiththeISO/IEC9899:1999standardanditisset-uptobehighlyportable.Thereforeitisindependentofhardwarearchitectureandcanbeincorporatedintolowcostmicro-controllerslike8051,AVR,PIC,ARMandetc...,justwithsmallportingcode.
ThisdocumentshowsyouhowtoconfigureanduseRBS.
FollowingdiagramshowstheRBSpositionintheentiresoftwarearchitecture:
RBSinApplication
FollowingdiagramshowstheRBSarchitecture:
RBSArchitecture
![Page 9: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/9.jpg)
RainbowBSFeaturesHardwareFeatures
Any8/16/32bitsCPUcanuseit.OnetimerandverylittleflashandRAMneeded.
SoftwareFeaturesPortable:RBSiswrittenbyClanguage,soitisportableonanyCcompilercompatiblewiththeC99standard.Configurable:RBShasbasecomponentsandoptionaladvancedcomponentslistedbelow.
BasicType
BasicMacros
System/CPUInfo.
MemoryOperation
Conversionrelated
base base base base base
Debug DynamicMemoryManagement
ProtothreadProcessModel
OSsupport
optional optional optional optional
OSIndependence:RBScanrunwithorwithoutOSsupport.Itoffersthread-safetyfeatureforOS.PCTools:RAutoConfigforgeneratingconfigurablefilebyUI.
![Page 10: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/10.jpg)
Requirements1. OnlyCPU,timer,RAMandflasharenecessaryinthetargetsystem.2. TheCcompilercompatiblewiththeISO/IEC9899:1999
standard(C99).
![Page 11: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/11.jpg)
LicenceRainbowBSisanopen-sourcebaselibraryforembeddedsystems.Thisisafreesoftwareandopenedforeducation,researchandcommercialdevelopmentsunderlicensepolicyoffollowingterms.
Copyright©2015-2016QWQ([email protected]).Allrightsreserved.
Redistributionanduseinsourceandbinaryforms,withorwithoutmodification,arepermittedprovidedthatthefollowingconditionsaremet:
Redistributionsofsourcecodemustretaintheabovecopyrightnotice,thislistofconditionsandthefollowingdisclaimer.Redistributionsinbinaryformmustreproducetheabovecopyrightnotice,thislistofconditionsandthefollowingdisclaimerinthedocumentationand/orothermaterialsprovidedwiththedistribution.Thenameoftheauthormaynotbeusedtoendorseorpromoteproductsderivedfromthissoftwarewithoutspecificpriorwrittenpermission.
THISSOFTWAREISPROVIDEDBYTHECOPYRIGHTHOLDERSANDCONTRIBUTORS"ASIS"ANDANYEXPRESSORIMPLIEDWARRANTIES,INCLUDING,BUTNOTLIMITEDTO,THEIMPLIEDWARRANTIESOFMERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSEAREDISCLAIMED.INNOEVENTSHALLCOPYRIGHTHOLDERSANDCONTRIBUTORSBELIABLEFORANYDIRECT,INDIRECT,INCIDENTAL,SPECIAL,EXEMPLARY,ORCONSEQUENTIALDAMAGES(INCLUDING,BUTNOTLIMITEDTO,PROCUREMENTOFSUBSTITUTEGOODSORSERVICES;LOSSOFUSE,DATA,ORPROFITS;ORBUSINESSINTERRUPTION)HOWEVERCAUSEDANDONANYTHEORYOFLIABILITY,WHETHERINCONTRACT,STRICTLIABILITY,ORTORT(INCLUDINGNEGLIGENCEOROTHERWISE)ARISINGINANYWAYOUTOFTHEUSEOFTHISSOFTWARE,EVENIF
![Page 12: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/12.jpg)
ADVISEDOFTHEPOSSIBILITYOFSUCHDAMAGE.
![Page 13: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/13.jpg)
ConventionsFollowingconventionsareusedinthisdocument
textusedfornormaltextitemusedforitememphasizeboldfontusedtoemphasizeprintf()usedforcodequotes
Generatedby 1.8.9.1
![Page 14: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/14.jpg)
TableofContents
Howtoportbasiccomponents
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
Chapter2BasicComponents
Basiccomponentsconsistoftype,macros,system/CPUinformation,memoryoperationanddigitconversion.
Typedefinationreferstobasictypes
Macrosreferstobasicmacros
Systemrelatedreferstosystemreleted
CPUrelatedreferstoCPUinformation
Memoryoperationrelatedreferstomemoryoperation
Digitconversionreferstoconversionreleted
![Page 15: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/15.jpg)
HowtoportbasiccomponentsSystem/CPUinformationneedsomemacrosdefinedinfileRainbowBSConf.h.
RBS_CFG_SYS_INFOindicatesastringwhichRBS_GetSysInfo()returns.
RBS_CFG_TICK_RATEindicatesthetimertickpersecond.
RBS_CFG_CPU_WORD_SIZEindicatessizewhichRBS_GetCPUBits()returns.
RBS_CFG_CPU_BYTE_ORDER_Lisdefinedto0or1whichRBS_IsCPULittleEndian()uses.
RBS_CFG_CPU_STACK_DOWNisdefinedto0or1whichRBS_IsStackGrowDown()uses.
Generatedby 1.8.9.1
![Page 16: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/16.jpg)
TableofContents
ApplicationModelIntroductionApplicationModelSupportedbyRBSProtothreadProcessLocalvariablesSchedulingImplementation
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
Chapter3ApplicationModel
![Page 17: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/17.jpg)
ApplicationModelIntroductionFromtheviewofapplicationdevelopersforanembeddedsystem,therearemainlytwowaystoconstructprogramforanapplication.
Event-Drivenapplicationmodel
Thismodelisverysuitableforsimpleapplications.Twomethodsareused,pollingorinterruptdriven.
Forpollingmethod,theprocessorcanwaitfordatareadytoprocessit,andwaitagain.Thepollingmethodworkswellforverysimpleapplications,butithasseveraldisadvantages.Forexample,whentheapplicationgetsmorecomplex,thepollingloopdesignmightgetverydifficulttomaintain.Also,itisdifficulttodefineprioritiesbetweendifferentservicesusingpollingandyoumightendupwithpoorresponsiveness,whereaperipheralrequestingservicemightneedtowaitalongtimewhiletheprocessorishandlinglessimportanttasks.Andlotsofenergyiswastedduringthepollingwhenserviceisnotrequired.
![Page 18: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/18.jpg)
pollingmethod
Forinterruptdrivenmethod,almostallmicro-controllershavesomesortofsleepmodesupporttoreducepower,inwhichtheperipheralcanwakeuptheprocessorwhenitrequiresaservice.Interruptsfromdifferentperipheralscanbeassignedwithdifferentinterruptprioritylevelssothatthisallowsmuchbetterresponsiveness..
![Page 19: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/19.jpg)
interruptdrivenmethod
Insomecases,theprocessingofdatafromperipheralservicescanbepartitionedintotwoparts:thefirstpartneedstobedonequickly,andthesecondpartcanbecarriedoutalittlebitlater.Insuchsituationswecanuseamixtureofinterrupt-drivenandpollingmethodstoconstructtheprogram.Whenaperipheralrequiresservice,ittriggersaninterruptrequestasinaninterrupt-drivenapplication.Oncethefirstpartoftheinterruptserviceiscarriedout,itupdatessomesoftwarevariablessothatthesecondpartoftheservicecanbeexecutedinthepolling-basedapplicationcode.
![Page 20: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/20.jpg)
mixedpollingandinterruptdrivenmethod
Usingthisarrangement,wecanreducethedurationofhigh-priorityinterrupthandlerssothatlowerpriorityinterruptservicescangetservedquicker.Atthesametime,theprocessorcanstillentersleepmodetosavepowerwhennoservicingisneeded.
Multi-Threadedapplicationmodel
Whentheapplicationsgetmorecomplex,apollingandinterrupt-drivenprogramstructuremightnotbeabletohandletheprocessingrequirements.Forexample,sometasksthatcantakealongtimetoexecutemightneedtobeprocessedconcurrently.Thiscanbedonebydividingtheprocessor’stimeintoanumberoftimeslotsandallocatingthetimeslotstothesetasks.Whileitistechnicallypossibletocreatesuchanarrangementbymanuallypartitioningthe
![Page 21: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/21.jpg)
tasksandbuildingasimpleschedulertohandlethis,itisoftenimpracticaltodothisinrealprojectsasitistimeconsumingandcanmaketheprogrammuchhardertomaintainanddebug.
Intheseapplications,aReal-TimeOperatingSystem(RTOS)canbeusedtohandlethetaskscheduling(Figure2.11).AnRTOSallowsmultipleprocessestobeexecutedconcurrently,bydividingtheprocessor’stimeintotimeslotsandallocatingthetimeslotstotheprocessesthatrequireservices.AtimerisneedtohandlethetimekeepingfortheRTOS,andattheendofeachtimeslot,thetimergeneratesatimerinterrupt,whichtriggersthetaskscheduleranddecidesifcontextswitchingshouldbecarriedout.Ifyes,thecurrentexecutingprocessissuspendedandtheprocessorexecutesanotherprocess.
multi-thresdedmethod
![Page 22: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/22.jpg)
ApplicationModelSupportedbyRBSTherearethreeoptionalapplicationmodeltowriteyourapplicationcodebasedonRBS.
NormalModel
Thisisanevent-drivensystemmodelsothatanendlessloopisneededinmain().
OSModel
Thisisamulti-threadedsystemmodelsothatanOSkernelisneeded.
PrptothreadProcessModel
Thisisanevent-drivensystemwithmulti-threadedlikedblockingproperty.
Protothreadsareaextremelylightweight,stacklesstypeofthreadsthatprovidesablockingcontextontopofanevent-drivensystem,withouttheoverheadofper-threadstacks.Thepurposeofprotothreadsistoimplementsequentialflowofcontrolwithoutcomplexstatemachinesorfullmulti-threading.ProtothreadsprovidesconditionalblockinginsideCfunctions.
Theadvantageofprotothreadsoverapurelyevent-drivenapproachisthatprotothreadsprovidesasequentialcodestructurethatallowsforblockingfunctions.Inpurelyevent-drivensystems,blockingmustbeimplementedbymanuallybreakingthefunctionintotwopieces-oneforthepieceofcodebeforetheblockingcallandoneforthecodeaftertheblockingcall.Thismakesithardtousecontrolstructuressuchasif()conditionalsandwhile()loops.
Theadvantageofprotothreadsoverordinarythreadsisthataprotothreaddonotrequireaseparatestack.Inmemoryconstrained
![Page 23: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/23.jpg)
systems,theoverheadofallocatingmultiplestackscanconsumelargeamountsoftheavailablememory.Incontrast,eachprotothreadonlyrequiresbetweentwoandtwelvebytesofstate,dependingonthearchitecture.
![Page 24: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/24.jpg)
ProtothreadProcessTheprotothreadslibrarywaswrittenbyAdamDunkelsadam@[email protected].
Protothreadsareaextremelylightweight,stacklessthreadsthatprovidesablockingcontextontopofanevent-drivensystem,withouttheoverheadofper-threadstacks.Thepurposeofprotothreadsistoimplementsequentialflowofcontrolwithoutusingcomplexstatemachinesorfullmulti-threading.ProtothreadsprovidesconditionalblockinginsideaCfunction.
Inmemoryconstrainedsystems,suchasdeeplyembeddedsystems,traditionalmulti-threadingmayhaveatoolargememoryoverhead.Intraditionalmulti-threading,eachthreadrequiresitsownstack,thattypicallyisover-provisioned.Thestacksmayuselargepartsoftheavailablememory.
Themainadvantageofprotothreadsoverordinarythreadsisthatprotothreadsareverylightweight:aprotothreaddoesnotrequireitsownstack.Rather,allprotothreadsrunonthesamestackandcontextswitchingisdonebystackrewinding.Thisisadvantageousinmemoryconstrainedsystems,whereastackforathreadmightusealargepartoftheavailablememory.Aprotothreadonlyrequiresonlytwobytesofmemoryperprotothread.Moreover,protothreadsareimplementedinpureCanddonotrequireanymachine-specificassemblercode.
AprotothreadrunswithinasingleCfunctionandcannotspanoverotherfunctions.AprotothreadmaycallnormalCfunctions,butcannotblockinsideacalledfunction.Blockinginsidenestedfunctioncallsisinsteadmadebyspawningaseparateprotothreadforeachpotentiallyblockingfunction.Theadvantageofthisapproachisthatblockingisexplicit:theprogrammerknowsexactlywhichfunctionsthatblockthatwhichfunctionstheneverblocks.
Protothreadsaresimilartoasymmetricco-routines.Themaindifferenceisthatco-routinesusesaseparatestackforeachco-routine,whereasprotothreadsarestackless.ThemostsimilarmechanismtoprotothreadsarePythongenerators.Thesearealsostacklessconstructs,buthavea
![Page 25: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/25.jpg)
differentpurpose.ProtothreadsprovidesblockingcontextsinsideaCfunction,whereasPythongeneratorsprovidemultipleexitpointsfromageneratorfunction.
Detailreferancestoprotothreadprocessprotothreadprocess
![Page 26: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/26.jpg)
LocalvariablesNote
Becauseprotothreadsdonotsavethestackcontextacrossablockingcall,localvariablesarenotpreservedwhentheprotothreadblocks.Thismeansthatlocalvariablesshouldbeusedwithutmostcare-ifindoubt,donotuselocalvariablesinsideaprotothread!
![Page 27: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/27.jpg)
SchedulingAprotothreadisdrivenbyrepeatedcallstothefunctioninwhichtheprotothreadisrunning.Eachtimethefunctioniscalled,theprotothreadwillrununtilitblocksorexits.Thustheschedulingofprotothreadsisdonebytheapplicationthatusesprotothreads.
![Page 28: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/28.jpg)
ImplementationProtothreadsareimplementedusinglocalcontinuations.Alocalcontinuationrepresentsthecurrentstateofexecutionataparticularplaceintheprogram,butdoesnotprovideanycallhistoryorlocalvariables.Alocalcontinuationcanbesetinaspecificfunctiontocapturethestateofthefunction.Afteralocalcontinuationhasbeensetcanberesumedinordertorestorethestateofthefunctionatthepointwherethelocalcontinuationwasset.
Localcontinuationscanbeimplementedinavarietyofways:
byusingmachinespecificassemblercode.byusingstandardCconstructs.byusingcompilerextensions.
Thefirstwayworksbysavingandrestoringtheprocessorstate,exceptforstackpointers,andrequiresbetween16and32bytesofmemoryperprotothread.Theexactamountofmemoryrequireddependsonthearchitecture.
ThestandardCimplementationrequiresonlytwobytesofstateperprotothreadandutilizestheCswitch()statementinanon-obviouswaythatissimilartoDuff'sdevice.Thisimplementationdoes,however,imposeaslightrestrictiontothecodethatusesprotothreadsinthatthecodecannotuseswitch()statementsitself.
CertaincompilershasCextensionsthatcanbeusedtoimplementprotothreads.GCCsupportslabelpointersthatcanbeusedforthispurpose.Withthisimplementation,protothreadsrequire4bytesofRAMperprotothread.
Generatedby 1.8.9.1
![Page 29: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/29.jpg)
TableofContents
DMMFeaturesMemoryBlockMemoryPoolUsageConfiguration
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
Chapter4DynamicMemoryManagment
Dynamicmemorymanagementisanoptionalcomponentformemoryusage.Itoffersbothmemoryblockandmemorypoolmechanism.
![Page 30: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/30.jpg)
DMMFeaturesmemoryblockoffersfixedsizememorymanagement.memorypooloffersvariablesizememorymanagement.bothmechanismssupportregister,byte-alignment,usagecheckandthread-safety.
![Page 31: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/31.jpg)
MemoryBlockregistermemoryblock
DependingontheRBS_CFG_APP_MODELconfigurationwhetherornotusingOS,oneoftworegisterinterfacesshouldbeusedbeforeusingmemoryblock.
IfRBS_CFG_APP_MODELisconfiguratedtoRBS_APP_OS,thread-safetyversionshouldbeused.
hDMMRBS_DMM_RegisterBlock(char*pName,void*pDM,USIZESize,USIZEBlockSize,HMUTEXhMutex)
IfRBS_CFG_APP_MODELisconfiguratedtoothers.
hDMMRBS_DMM_RegisterBlock(char*pName,void*pDM,USIZESize,USIZEBlockSize)
allocateandfreeblock
hBLOCKRBS_DMM_AllocZeroBlock(hDMMhDmm)
hBLOCKRBS_DMM_AllocBlock(hDMMhDmm)
BOOLRBS_DMM_FreeBlock(hBLOCKhBlock)
blockusage
void*RBS_DMM_UseHBlock(hBLOCKhBlock)
BOOLRBS_DMM_UnuseHBlock(hBLOCKhBlock)
![Page 32: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/32.jpg)
MemoryPoolregistermemorypool
DependingontheRBS_CFG_APP_MODELconfigurationwhetherornotusingOS,oneoftworegisterinterfacesshouldbeusedbeforusingmemorypool.
IfRBS_CFG_APP_MODELisconfiguratedtoRBS_APP_OS,thread-safetyversionshouldbeused.
hDMMRBS_DMM_RegisterPool(char*pName,void*pDM,USIZESize,BOOLbAntiFrag,U16HCount,HMUTEXhMutex)
IfRBS_CFG_APP_MODELisconfiguratedtoothers.
hDMMRBS_DMM_RegisterPool(char*pName,void*pDM,USIZESize,BOOLbAntiFrag,U16HCount)
allocateandfreepool
hMEMRBS_DMM_AllocZeroMem(hDMMhDmm,USIZEsize)
hMEMRBS_DMM_AllocMem(hDMMhDmm,USIZEsize)
hMEMRBS_DMM_ReallocMem(hMEMhMem,USIZEsize)
BOOLRBS_DMM_FreeMem(hMEMhMem)
poolusage
void*RBS_DMM_UseHMem(hMEMhMem)
BOOLRBS_DMM_UnuseHMem(hMEMhMem)
USIZERBS_DMM_GetHMemSize(hMEMhMem)
![Page 33: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/33.jpg)
UsageInanembeddedsystem,therearesomememorytypeswithdifferentsizesuchasinternalSRAMintegratedinmicro-controller,externalSDRAM,SRAM,etc...andthosememorycanbebyte-addressedinthesameaddressspace.Someofthemareusedforstacks,whilesomeusedforglobaldataandsomeusedfordynamicmemoryallocation.Sothespecificusageofthosememoryaredecidedbytheapplication.
UnliketraditionalmemorymanagementlikemallocinClibrary,DMMcanmanagemorethanonecontinuousbyte-addressedmemoryfordynamicmemoryallocationandcanbesensitivetomemoryusage.
Asanexample,amicro-controllerhas8K-bytessizeinternalRAMinandexternal2M-bytesSDRAM.Youwanttouse2K-bytesinternalRAMand1M-bytesexternalSDRAMspacefordynamicmemoryallocation.Firstofall,youjustdefinetwobytearray,oneforthe2KinternalRAMandtheotherforthe1M-bytesexternalSDRAM,andtheusetheregisterinterfacetodefinethetwomemoryspace.Afterregister,youcanallocatememoryfromthembytheDMMhandlereturnedfromregister.
Allocatedmemorywillreturnamemoryhandleandthenyoucanusethememoryhandletouse,notuseorfreetheallocatedmemory.
UsingRBS_DMM_UseHBlock()orRBS_DMM_UseHMem()torefertotheallocatedmemoryspace.
UsingRBS_DMM_UnuseHBlock()orBS_DMM_UnuseHMem()tonotifytheDMMtoendthelastmemoryreferance.
UsingRBS_DMM_FreeBlock()orRBS_DMM_FreeMem()tonotifytheDMMtoreleasethememory.
RBS_DMM_UseHBloc()andBRS_DMM_UnuseHBlock()areusedinpair,whileRBS_DMM_UseHMem()andRBS_DMM_UnuseHMem()areinpair.Thereasonisthateachmemoryhandlehasareferancecounterininternal,andthecounterisincreasedby1perusageanddecreaseby1pernousage.Soifthecounterisnotinitialvalue,itwillnotbereleased
![Page 34: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/34.jpg)
successfullybyRBS_DMM_FreeBlock()orRBS_DMM_FreeMem().Thisiscalledusagecheck.DevelopersshouldkeepinmindthataftereachreferencetotheallocatedmemorybyRBS_DMM_UseHBlock()orRBS_DMM_UseHMem(),anRBS_DMM_UnuseHBlock()orRBS_DMM_UnuseHMem()shouldbecalledandifhewantstorefertothememoryagain,thenRBS_DMM_UseHBlock()orBS_DMM_UseHMem()shouldbecalledagain.Withusagecheck,developerswillfindmemoryusageconflictsandbugsearlier.Forexample,therearetworunningtasksAandBthatbothusinganallocatedmemory.IftaskAisusingthememorywithoutcallingRBS_DMM_UnuseHBlock()orRBS_DMM_UnuseHMem()andtaskBcallRBS_DMM_FreeBlock()orRBS_DMM_FreeMem(),thenanerrorinformationwillbeprintedbydebugcomponent,tellingthatitcannotreleasememoryhandlebecauseitisusing.
RememberthatusagecheckisonlyeffectiveifRBSdebugcomponentisenabled,otherwiseusagecheckisdisabled.FollowingistheexamplecodeforDMMusage.
1 /*definearray*/
2 U8aInternalRAM[2048]
__attribute__((at(0x20000000)));//2K-bytes
internalRAMstartingfrom0x20000000
3 U8aExternalRAM[1024*1024]
__attribute__((at(0x08011000)));//1M-bytes
externalSDRAMstartingfrom0x08011000
4 /*register*/
5 hDMMhBlockDMM=RBS_DMM_RegisterBlock("Block
DMM",aInternalRAM,sizeof(aInternalRAM),60);//re
gisteramemoryblockwith60bytesperblock.
6 hDMMhPoolDMM=RBS_DMM_RegisterPool("Pool
DMM",aExternalRAM,sizeof(aExternalRAM),FALSE,20
0);//registeramemorypoolwith200handle
available.
7 /*allocate*/
8 hBLOCKhBlock=
RBS_DMM_AllocBlock(hBlockDMM);//allocatea
blockfromhBlockDMM
![Page 35: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/35.jpg)
9 hMEMhMem=
RBS_DMM_AllocMem(hPoolDMM,200);//allocate200
bytesfromhPoolDMM
10 /*reference*/
11 void*pBlock=
RBS_DMM_UseHBlock(hBlock);//usinghBlock
12 void*pMem=RBS_DMM_UseHMem(hMem);//using
hMem
13 ...//usingmemory
14 RBS_DMM_UnuseHBlock(hBlock);//notusehBlock
15 RBS_DMM_UnuseHMem(hMem);//unusinghMem
16 /*free*/
17 RBS_DMM_FreeBlock(hBlock);//releasehBlock
18 RBS_DMM_FreeMem(hMem);//releasehMem
![Page 36: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/36.jpg)
ConfigurationRBS_CFG_DMM_ALIGNisdefinedfordefinebyte-alignment.3means8bytes,2means4bytes,1means2bytes,0means1bytes.
Allocatedmemorystartedaddressandsizearebothalignment.SoifRBS_CFG_DMM_ALIGNis2andyouallocated25bytes,thenyouget28bytesactually.
Generatedby 1.8.9.1
![Page 37: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/37.jpg)
TableofContents
DebugFeaturesDebugUsageHowtoconfiguredebugcomponentHowtoportdebugcomponent
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
Chapter5Debug
DebugisimportantforsoftwaredevelopmentandRBScontainsausefuldebugcomponent.Detailreferencestodebug
![Page 38: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/38.jpg)
DebugFeaturesfouroptionaldebuglevels:none,error,warning,logoutputre-targetingthread-safetysupport
![Page 39: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/39.jpg)
DebugUsageFourtypesdebugmacrosareavailable.
debugstatement
RBS_DEBUG_STA(sta)
RBS_DEBUG_IF(exp,sta)
RBS_DEBUG_ELSIF(sta1,exp,sta2)
RBS_DEBUG_ENDIF(sta)
debugerroroutput
RBS_DEBUG_ERROR(exp,s)
RBS_DEBUG_ERROR_FORMAT(exp,format,...)
debugwarningoutput
RBS_DEBUG_WARN(exp,s)
RBS_DEBUG_WARN_FORMAT(exp,format,...)
debuglogoutput
RBS_DEBUG_LOG(s)
RBS_DEBUG_LOG_FORMAT(format,...)
![Page 40: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/40.jpg)
HowtoconfiguredebugcomponentTherearetwomacroconfigurationfordebugcomponent.
RBS_CFG_DEBUG_LEVEListheconfigurationfordebuglevel.YoucandefineRBS_CFG_DEBUG_LEVELfromoneofthefouroptionaldebuglevelsmacros.
RBS_DEBUG_LEVEL_NOCHECKdisablealldebugstatementandoutputRBS_DEBUG_LEVEL_ERRORSonlyenabledebugstatementanddebugerroroutputRBS_DEBUG_LEVEL_WARNINGSdebugwarningoutputplusBS_DEBUG_LEVEL_ERRORS
RBS_DEBUG_LEVEL_ALLdebuglogoutputplusBS_DEBUG_LEVEL_WARNINGS
RBS_CFG_DEBUG_BUFSIZEcofigurethedebugbuffersizeinbytes.Defaultsizeis300bytes.Oneoutputstringlengthshouldnotexceeddebugbuffersize.
![Page 41: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/41.jpg)
HowtoportdebugcomponentDependingtodebuglevelyouconfigureRBS_CFG_DEBUG_LEVEL,differentportingfunctionsareneeded.Andyoucanre-targetingoutputbytheseportingfunctions.
RBS_DEBUG_LEVEL_ERRORSneeds:
voidPort_Printf_Error(constchar*s)fordebugerroroutput
RBS_DEBUG_LEVEL_WARNINGSneeds:
voidPort_Printf_Error(constchar*s)fordebugerroroutputvoidPort_Printf_Warn(constchar*s)fordebugwarningoutput
BS_DEBUG_LEVEL_ALLneeds:
voidPort_Printf_Error(constchar*s)fordebugerroroutputvoidPort_Printf_Warn(constchar*s)fordebugwarningoutputvoidPort_Printf_Log(constchar*s)fordebuglogoutput
IfapplicationmodelRBS_CFG_APP_MODELisconfiguredtoRBS_APP_OS,thenOSlocksuchasmutexorsemaphoreshouldusedforthread-safedebug.
Debugerroroutput(RBS_DEBUG_LEVEL_ERRORS),debugwarningoutput(RBS_DEBUG_LEVEL_WARNINGS)anddebuglog(RBS_DEBUG_LEVEL_ALL)outputusethesamelock.Andthreefollowingportingfunctionsshouldbepresent.
BOOLPort_Init(void)forcreatingdebuglockBOOLPort_GetMutex(HMUTEXhMutex)forlockdebugoutputBOOLPort_FreeMutex(HMUTEXhMutex)forunlockdebugoutput
Generatedby 1.8.9.1
![Page 42: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/42.jpg)
TableofContents
ConfigurationclassSystemandCPUApplicationmodelDMMDebug
UsingRAutoConfig
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
Chapter6Configration
RBSconfigurationisdefinedbyfileRainbowBSConf.h.YoucanwriteormodifythisfileorusePCtoolRAutoConfig.exetogeneratethisfile.
![Page 43: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/43.jpg)
ConfigurationclassSystemandCPU
RBS_CFG_SYS_INFO
defineastringfordescribingtheapplication.
RBS_CFG_TICK_RATE
timertickpersecond.Thevalidvalueshouldbeinrangof1to1000and1000shouldbedividedwithnoremainderbyit.
RBS_CFG_CPU_WORD_SIZE
definitionofCPUwordsize8bits/16bits/32bits.
RBS_CFG_CPU_BYTE_ORDER_L
CPUbyteorder.1meanslittle-endiaand0meansbig-endia.
RBS_CFG_CPU_STACK_DOWN
stackgrowthdirection.1meansgrowingtolowaddressand0meansgrowingtohighaddress.
![Page 44: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/44.jpg)
ApplicationmodelRBS_CFG_APP_MODEL
oneofthreeapplicationmodelsshouldbechosen.
RBS_APP_NONEtraditionalevent-drivenmodel.RBS_APP_PTPprotothreadevent-drivenmodel.RBS_APP_OSmultitaskmodel.OSkernelneeded.
HMUTEX
typeofmutexdefinedbyOSused.ThishaseffectonlywhenRBS_CFG_APP_MODELisconfiguredtoRBS_APP_OS.
Headfilename
headfileofferedbyOSused.ThishaseffectonlywhenRBS_CFG_APP_MODELisconfiguredtoRBS_APP_OS.
RBS_CFG_PTP_NO_PROCESS_NAME
processname.1meansdisabled,0meansenabled.ThishaseffectonlywhenRBS_CFG_APP_MODELisconfiguredtoRBS_APP_PTP.
RBS_CFG_PTP_PROCESS_STATS
usedtostatisticsforeventsused.1meansenabled,0meansdisabled.ThishaseffectonlywhenRBS_CFG_APP_MODELisconfiguredtoRBS_APP_PTP.
RBS_CFG_PTP_NUMEVENTS
eventcount.ThishaseffectonlywhenRBS_CFG_APP_MODELisconfiguredtoRBS_APP_PTP.
![Page 45: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/45.jpg)
DMMRBS_CFG_DMM_ALIGN
definethealignmentbytesformemoryaddressandsize.3means8bytes,2means4bytes,1means2bytes,0means1byte.
![Page 46: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/46.jpg)
DebugRBS_CFG_DEBUG_LEVEL
debugoutputlevel.oneoffourshouldbechosen.
RBS_DEBUG_LEVEL_NOCHECKdisabledebugoutput.norunningtimechecksareperformed.RBS_DEBUG_LEVEL_ERRORSerrorsarerecorded.RBS_DEBUG_LEVEL_WARNINGSerrorsandwarningsarerecorded.RBS_DEBUG_LEVEL_LOGerrors,warningsandlogsarerecorded.
RBS_CFG_DEBUG_BUFSIZE
outputbufferlength.ThishaseffectonlywhenRBS_CFG_DEBUG_LEVELisnotconfiguredtoRBS_DEBUG_LEVEL_NOCHECK.
![Page 47: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/47.jpg)
UsingRAutoConfigRAutoConfigisin"RainbowBS\RBSTools".
RainbowAutoConfig
Generatedby 1.8.9.1
![Page 48: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/48.jpg)
TableofContents
PortedonPCPortedonCortex-M
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
Chapter7PortingandExample
Currently,RBShasbeenportedonPCandARMCortex-MMCU.Alsoitcanbeportedonanyotherarchitecturebyreferencetothat.
Recommendprojectfilearchitectureasfollowing:
FileArchitecture
![Page 49: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/49.jpg)
PortedonPCRefertotheexamplein"RainbowBS/RBSDemoProjects/X86_VS2008/RBSDemo_VS2008.sln".TherearethreeconfigurationtargetscorrespondingtothethreeRBSapplicationmodelsrespectively.
![Page 50: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/50.jpg)
PortedonCortex-MRefertotheexamplein"RainbowBS/RBSDemoProjects/STM32F4_MDK/RBSDemo_STM32F4.uvprojx".TherearethreeconfigurationtargetscorrespondingtothethreeRBSapplicationmodelsrespectively.ThestandardoutputisdefinedtouseSWOintheexample.YoucanuseKeil-MDKDebugViewerorJLinkSWOViewer(ifJLinkisusedasadaptor)toview.
OutputinDebugViewer
![Page 52: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/52.jpg)
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
Modules
Hereisalistofallmodules:[detaillevel 1 2 ]
RBSconfigration basictypes basicmacros systemreleted CPUinformation memoryoperation conversionreleted dynamicmemorymanagement protothreadprocess Eventtimers debug▼Pt Localcontinuations Protothreadsemaphores
Generatedby 1.8.9.1
![Page 54: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/54.jpg)
Macros#define RBS_CFG_SYS_INFO"RainbowSys"#define RBS_CFG_TICK_RATE100#define RBS_CFG_CPU_WORD_SIZE32/*CPUwordsize*/#define RBS_CFG_CPU_BYTE_ORDER_L1/*CPUbyteorder*/
#define RBS_CFG_CPU_STACK_DOWN1/*stackgrowthdirection*/
#define RBS_APP_NONE0#define RBS_APP_PTP1#define RBS_APP_OS2#define RBS_CFG_APP_MODELRBS_APP_PTP#define RBS_CFG_PTP_NO_PROCESS_NAME0#define RBS_CFG_PTP_PROCESS_STATS0#define RBS_CFG_PTP_NUMEVENTS32#define RBS_CFG_DMM_ALIGN2
#define RBS_DEBUG_LEVEL_NOCHECK0/*Norunningtimechecksareperformed*/#define RBS_DEBUG_LEVEL_ERRORS1/*Errorsarerecorded*/
#define RBS_DEBUG_LEVEL_WARNINGS2/*ErrorsandWarningsarerecorded*/
![Page 55: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/55.jpg)
#define RBS_DEBUG_LEVEL_LOG3/*Errors,Warningsandlogsarerecorded*/
#define RBS_CFG_DEBUG_BUFSIZE300#define RBS_CFG_DEBUG_LEVELRBS_DEBUG_LEVEL_LOG
![Page 58: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/58.jpg)
Typedefstypedefuint8_t BOOL
typedefint8_t I8
typedefuint8_t U8
typedefint16_t I16
typedefuint16_t U16typedefint32_t I32
typedefuint32_t U32typedefint64_t I64
typedefuint64_t U64
typedefsize_t USIZEtypedefptrdiff_t IPTRDIFF
typedefU64 TICK
![Page 61: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/61.jpg)
Macros#define FALSE0u#define TRUE1u#define USE_PARA(para)(para=(para))#define MIN(v0,v1)(((v0)>(v1))?(v1):(v0))#define MAX(v0,v1)(((v0)>(v1))?(v0):(v1))#define ABS(v)(((v)>=0)?(v):(-(v)))#define SWAP(a,b)(a=(a)+(b),b=(a)-(b),a=(a)-(b))#define COUNT_OF(a)(sizeof(a)/sizeof(a[0]))#define _STR(a)#a#define STR(a)_STR(a)#define _CONS(a,b)a##b#define CONS(a,b)_CONS(a,b)
#define ALIGN_F(pointer,power2)(((IPTRDIFF)(pointer)+((IPTRDIFF)((power2)-1)))&(~((IPTRDIFF)((power2)-1))))
#define ALIGN_B(pointer,power2)((IPTRDIFF)(pointer)&(~((IPTRDIFF)((power2)-1))))
![Page 64: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/64.jpg)
DataStructuresstruct tTime Timestructure.More...
![Page 65: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/65.jpg)
FunctionsBOOL RBS_Init(void) InitializeRainbowBS.More...
![Page 66: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/66.jpg)
systeminformationconstchar* RBS_GetVersionString(void) GetRainbowBSversionstring.More...constchar* RBS_GetSysInfo(void) Getsystemdescriptionstring.More...
![Page 67: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/67.jpg)
timereleatedTICK RBS_GetTickCount(void)
Getsystemtick.More...
U64 RBS_GetRunTime(void) Getsystemrunningtime(ms).More...
void RBS_GetLocalTime(tTime*ptTime) Getsystemlocaltime.More...
void RBS_Delay(U32milliseconds) Delaysomemilliseconds.More...#define RBS_TICK_MS(1000u/RBS_CFG_TICK_RATE)
![Page 68: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/68.jpg)
DetailedDescription
Implementationofsystemreleted.
![Page 69: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/69.jpg)
FunctionDocumentation
voidRBS_Delay ( U32 milliseconds )
Parameters[in]millisecondsmillisecondcount.
Hereisthecallgraphforthisfunction:
voidRBS_GetLocalTime ( tTime* ptTime )
Parameters[out] ptTime localtimepointer.
SeealsoRBS_GetRunTime()
Hereisthecallgraphforthisfunction:
U64RBS_GetRunTime ( void )
Returnssystemrunningtimeinmillisecond.
SeealsoRBS_GetLocalTime()
Hereisthecallgraphforthisfunction:
![Page 70: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/70.jpg)
constchar*RBS_GetSysInfo ( void )
Returnssystemdescriptionstring.
SeealsoRBS_GetVersionString()
TICKRBS_GetTickCount ( void )
Returnssystemtick.
Hereisthecallgraphforthisfunction:
Hereisthecallergraphforthisfunction:
constchar*RBS_GetVersionString ( void )
Returnsversionstring.
SeealsoRBS_GetSysInfo()
BOOLRBS_Init ( void )
ReturnvaluesTRUE successfully.
![Page 71: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/71.jpg)
FALSE failed.
Hereisthecallgraphforthisfunction:
Generatedby 1.8.9.1
![Page 72: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/72.jpg)
DataFields
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
tTimeStructReferencesystemreleted
Timestructure.
#include<RainbowBS.h>
CollaborationdiagramfortTime:
![Page 73: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/73.jpg)
DataFieldsU16 yearU8 month
U8 day
U8 day_of_week
U8 hour
U8 minute
U8 second
U16 milliseconds
![Page 74: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/74.jpg)
FieldDocumentation
U8day
dayofmonth[1,31]
U8day_of_week
dayofweek[0,6]
U8hour
hour[0,23]
U16milliseconds
milliseconds[0,999]
U8minute
minute[0,59]
U8month
month[1,12]
U8second
![Page 75: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/75.jpg)
second[0,59]
U16year
year[1601,30827]
Thedocumentationforthisstructwasgeneratedfromthefollowingfile:
RainbowBS.h
Generatedby 1.8.9.1
![Page 77: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/77.jpg)
FunctionsU8 RBS_GetCPUBits(void)
CPUword-width.More...BOOL RBS_IsCPULittleEndian(void) CheckifCPUislittle-endian.More...BOOL RBS_IsStackGrowDown(void) Checkifstackgrowsdown.More...
![Page 78: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/78.jpg)
DetailedDescription
InformationaboutCPU.
![Page 79: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/79.jpg)
FunctionDocumentation
U8RBS_GetCPUBits ( void )
ReturnsCPUword-width(8/16/32/64).
BOOLRBS_IsCPULittleEndian ( void )
ReturnvaluesTRUE little-endian.FALSE big-endian.
BOOLRBS_IsStackGrowDown ( void )
ReturnvaluesTRUE growthdown.FALSE growthup.
Generatedby 1.8.9.1
![Page 81: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/81.jpg)
Functionsvoid RBS_MemSet8(U8*pDes,U8fill,USIZEnum) Setmemorybybyteunit.More...void RBS_MemSet16(U16*pDes,U16fill,USIZEnum) Setmemorybytwo-bytesunit.More...void RBS_MemSet32(U32*pDes,U32fill,USIZEnum) Setmemorybyfour-bytesunit.More...void RBS_MemCpy8(U8*pDes,constU8*pSrc,USIZEnum) Copymemorybybyteunit.More...U16 RBS_Read16L(constU8**ppData) Reada16-bitsentityinlittle-endian.More...U32 RBS_Read32L(constU8**ppData) Reada32-bitsentityinlittle-endian.More...void RBS_Write16L(U8**ppData,U16data) Writea16-bitsentityinlittle-endian.More...void RBS_Write32L(U8**ppData,U32data) Writea32-bitsentityinlittle-endian.More...U16 RBS_Read16B(constU8**ppData) Reada16-bitsentityinbig-endian.More...U32 RBS_Read32B(constU8**ppData) Reada32-bitsentityinbig-endian.More...void RBS_Write16B(U8**ppData,U16data) Writea16-bitsentityinbig-endian.More...
![Page 82: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/82.jpg)
void RBS_Write32B(U8**ppData,U32data) Writea32-bitsentityinbig-endian.More...
![Page 83: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/83.jpg)
DetailedDescription
Memorysetandcopyoperation.
![Page 84: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/84.jpg)
FunctionDocumentation
voidRBS_MemCpy8 ( U8* pDes,constU8* pSrc,USIZE num)
Parameters[out] pDes destinationpointer.[in] pSrc sourcepointer.[in] num totalunits.
Hereisthecallergraphforthisfunction:
voidRBS_MemSet16 ( U16* pDes,U16 fill,USIZE num)
Parameters[out] pDes destinationpointer(two-bytesalignment).[in] fill two-bytesfilled.[in] num totalunits.
voidRBS_MemSet32 ( U32* pDes,U32 fill,USIZE num)
![Page 85: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/85.jpg)
Parameters[out] pDes destinationpointer(four-bytesalignment).[in] fill four-bytesfilled.[in] num totalunits.
voidRBS_MemSet8 ( U8* pDes,U8 fill,USIZE num)
Parameters[out] pDes destinationpointer.[in] fill bytefilled.[in] num totalunits.
Hereisthecallergraphforthisfunction:
U16RBS_Read16B ( constU8** ppData )
Parameters[in,out] ppData datapointer,added2bytesaftercalling.
Returnsdataentity
U16RBS_Read16L ( constU8** ppData )
Parameters[in,out] ppData datapointer,added2bytesaftercalling.
![Page 86: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/86.jpg)
Returnsdataentity
U32RBS_Read32B ( constU8** ppData )
Parameters[in,out] ppData datapointer,added4bytesaftercalling.
Returnsdataentity
U32RBS_Read32L ( constU8** ppData )
Parameters[in,out] ppData datapointer,added4bytesaftercalling.
Returnsdataentity
voidRBS_Write16B ( U8** ppData,U16 data)
Parameters[in,out] ppData datapointer,added2bytesaftercalling.[in] data datatobewtitten.
voidRBS_Write16L ( U8** ppData,U16 data)
Parameters[in,out] ppData datapointer,added2bytesaftercalling.
![Page 87: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/87.jpg)
[in] data datatobewtitten.
voidRBS_Write32B ( U8** ppData,U32 data)
Parameters[in,out] ppData datapointer,added4bytesaftercalling.[in] data datatobewtitten.
voidRBS_Write32L ( U8** ppData,U32 data)
Parameters[in,out] ppData datapointer,added4bytesaftercalling.[in] data datatobewtitten.
Generatedby 1.8.9.1
![Page 89: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/89.jpg)
convertdigittostringenum ePOW{SHEX,SBINARY,SDECIMAL} Specifichex,binaryordecimal.More...
U8 RBS_Number2String(U32value,ePOWePow,U8length,char*pText)
ConvertunsigneddigittoASCIIstring.More...
![Page 90: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/90.jpg)
trigonometricreletedint RBS_sin(intangle)
Calculatesine.More...
int RBS_cos(intangle) Calculatecosine.More...
int RBS_tan(intangle) Calculatetangent.More...
int RBS_ctan(intangle) Calculatecotangent.More...#define ANG_45DEG1024#define ANG_90DEG(2*ANG_45DEG)#define ANG_135DEG(3*ANG_45DEG)#define ANG_180DEG(4*ANG_45DEG)#define ANG_225DEG(5*ANG_45DEG)#define ANG_270DEG(6*ANG_45DEG)#define ANG_315DEG(7*ANG_45DEG)#define ANG_360DEG(8*ANG_45DEG)
![Page 91: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/91.jpg)
DetailedDescription
EnumerationTypeDocumentation
enumePOW
Enumerator
SHEX hexSBINARY binarySDECIMAL decimal
![Page 92: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/92.jpg)
FunctionDocumentation
intRBS_cos ( int angle )
Thisfunctioncalculatescosinewithoutusingfloat-pointnumbers.Ituseaconstanttabletolookupfortheappropriatevalue.
Parameters[in] angle angle=degrees*ANG_45DEG/45,degrees=angle*45/ANG_45DEG.
Returnscos(degrees)*1024.
intRBS_ctan ( int angle )
Thisfunctioncalculatescotangentwithoutusingfloat-pointnumbers.Ituseaconstanttabletolookupfortheappropriatevalue.
Parameters[in] angle angle=degrees*ANG_45DEG/45,degrees=angle*45/ANG_45DEG.
Returnscotan(degrees)*1024.
U8RBS_Number2String ( U32 value,ePOW ePow,U8 length,char* pText)
Parameters[in] value unsigneddigit.
![Page 93: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/93.jpg)
[in] ePow choosehex,binaryordecimal.[in] lengthMax.bitsfromlowestbit.IfLenis0,choosing
Min.charactersautomatically.[out] pText outputstringbuffer.
Returnscharacternumber.
SeealsoePOW
intRBS_sin ( int angle )
Thisfunctioncalculatessinewithoutusingfloat-pointnumbers.Ituseaconstanttabletolookupfortheapproximatevalue.
Parameters[in] angle angle=degrees*ANG_45DEG/45,degrees=angle*45/ANG_45DEG.
Returnssin(degrees)*1024.
Example:
1 //calculatesineof30degrees,thereturnvalueis
511which
2 //isapproximatelyequaltosin30*1024whichis512.
3 intvalue=RBS_sin(30*ANG_45DEG/45);
intRBS_tan ( int angle )
Thisfunctioncalculatestangentwithoutusingfloat-pointnumbers.Ituseaconstanttabletolookupfortheappropriatevalue.
Parameters[in] angle angle=degrees*ANG_45DEG/45,degrees=angle*45/ANG_45DEG.
![Page 95: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/95.jpg)
Macros|Typedefs|Functions
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
dynamicmemorymanagement
![Page 96: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/96.jpg)
Macros#define HDMM_NULLNULL#define HBLOCK_NULLNULL#define HMEM_NULLNULL
![Page 97: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/97.jpg)
Typedefstypedefvoid* hDMMtypedefvoid* hBLOCKtypedefvoid* hMEM
![Page 98: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/98.jpg)
Functions
hDMM RBS_DMM_RegisterBlock(char*pName,void*pDM,USIZEsize,USIZEblock_size,HMUTEXhMutex)
Registerthememoryareaasadynamicblockmemoryarea.More...
hBLOCK RBS_DMM_AllocZeroBlock(hDMMhDmm) Allocateafreeblockwithzeroinitializationfromthedynamic
blockmemoryarea.More...hBLOCK RBS_DMM_AllocBlock(hDMMhDmm) Allocateafreeblockfromthedynamicblockmemoryarea.
More...
BOOL RBS_DMM_FreeBlock(hBLOCKhBlock) Freetheallocatedblock.More...
void* RBS_DMM_UseHBlock(hBLOCKhBlock) Gettheallocatedblockpointer.More...
BOOL RBS_DMM_UnuseHBlock(hBLOCKhBlock) Unusetheallocatedblockarea.More...
hDMM RBS_DMM_RegisterPool(char*pName,void*pDM,USIZEsize,BOOLbAntiFrag,U16handle_count,HMUTEXhMutex)
Registerthememoryareaasadynamicpoolmemoryarea.More...
hMEM RBS_DMM_AllocZeroMem(hDMMhDmm,USIZEsize)
Allocateafreememorywithzeroinitializationfromthedynamicmemoryarea.More...
hMEM RBS_DMM_AllocMem(hDMMhDmm,USIZEsize)
Allocateafreememoryfromthedynamicmemoryarea.More...
![Page 99: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/99.jpg)
hMEM RBS_DMM_ReallocMem(hMEMhMem,USIZEsize)
Reallocateafreememoryfromthesamedynamicmemoryarea.More...
BOOL RBS_DMM_FreeMem(hMEMhMem)
Freetheallocatedmemory.More...
void* RBS_DMM_UseHMem(hMEMhMem) Gettheallocatedmemorypointer.More...
BOOL RBS_DMM_UnuseHMem(hMEMhMem) Unusetheallocatedmemoryarea.More...
USIZE RBS_DMM_GetHMemSize(hMEMhMem) Gettheallocatedmemorysize.More...
![Page 100: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/100.jpg)
DetailedDescription
Dynamicmemorymanagementforbothmemorypollandblock.
![Page 101: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/101.jpg)
FunctionDocumentation
hBLOCKRBS_DMM_AllocBlock ( hDMM hDmm )
Parameters[in] hDmm handleofdynamicblockmemoryarea.
ReturnvaluesHBLOCK_NULL failed.others handleofdynamicmemoryarea.
Hereisthecallgraphforthisfunction:
Hereisthecallergraphforthisfunction:
hMEMRBS_DMM_AllocMem ( hDMM hDmm,USIZE size)
Parameters[in] hDmm handleofdynamicmemoryarea.[in] size memoryareabytes.
ReturnvaluesHMEM_NULL failed.others handleofdynamicmemoryarea.
![Page 102: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/102.jpg)
Hereisthecallgraphforthisfunction:
Hereisthecallergraphforthisfunction:
hBLOCKRBS_DMM_AllocZeroBlock ( hDMM hDmm )
Parameters[in] hDmm handleofdynamicblockmemoryarea.
ReturnvaluesHBLOCK_NULL failed.others handleofdynamicmemoryarea.
Hereisthecallgraphforthisfunction:
hMEMRBS_DMM_AllocZeroMem ( hDMM hDmm,USIZE size)
Parameters[in] hDmm handleofdynamicmemoryarea.[in] size memoryareabytes.
![Page 103: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/103.jpg)
ReturnvaluesHMEM_NULL failed.others handleofdynamicmemoryarea.
Hereisthecallgraphforthisfunction:
BOOLRBS_DMM_FreeBlock ( hBLOCK hBlock )
Parameters[in] hBlock handleofaallocatedblock.
ReturnvaluesTRUE successful.FALSE failed.
Hereisthecallgraphforthisfunction:
BOOLRBS_DMM_FreeMem ( hMEM hMem )
Parameters[in] hMem handleofaallocatedmemory.
Returnvalues
![Page 104: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/104.jpg)
TRUE successful.FALSE failed.
Hereisthecallgraphforthisfunction:
USIZERBS_DMM_GetHMemSize ( hMEM hMem )
Parameters[in] hMem handleoftheallocatedmemory.
Returnsmemoryareasize.
Hereisthecallgraphforthisfunction:
hMEMRBS_DMM_ReallocMem ( hMEM hMem,USIZE size)
Parameters[in] hMem handleofanallocatedmemory.[in] size memoryareabytes.
ReturnvaluesHMEM_NULL failed.others handleofdynamicmemoryarea.
Hereisthecallgraphforthisfunction:
![Page 105: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/105.jpg)
hDMMRBS_DMM_RegisterBlock ( char* pName,void* pDM,USIZE size,USIZE block_size,HMUTEX hMutex)
Parameters[in] pName blockmemoryname.[in] pDM pointertotheblockmemoryarea.[in] size blockmemoryareasize(bytes).[in] block_size eachblocksize.[in] hMutex memoryblockmutexforthread-safe.IfNULL,no
thread-safesupport.
ReturnvaluesHDMM_NULL failed.other handleofdynamicblockmemoryarea.
Hereisthecallgraphforthisfunction:
Hereisthecallergraphforthisfunction:
![Page 106: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/106.jpg)
hDMMRBS_DMM_RegisterPool ( char* pName,void* pDM,USIZE size,BOOL bAntiFrag,U16 handle_count,HMUTEX hMutex)
Parameters[in] pName memorypoolname.[in] pDM pointertothememoryarea.[in] size memoryareasize(bytes).[in] bAntiFrag enabledefragmentation.[in] handle_count countofmemoryhandles.[in] hMutex memorypoolmutexforthread-safety.If
NULL,nothread-safesupport.
ReturnvaluesNot HDMM_NULLsuccessful.HDMM_NULL failed.
Hereisthecallgraphforthisfunction:
Hereisthecallergraphforthisfunction:
BOOLRBS_DMM_UnuseHBlock ( hBLOCK hBlock )
Parameters[in] hBlock handleofaallocatedblock.
![Page 107: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/107.jpg)
Returnsblockareapointer.
SeealsoRBS_DMM_UseHBlock()
NoteusedinpairwithRBS_DMM_UseHBlock()
Hereisthecallgraphforthisfunction:
Hereisthecallergraphforthisfunction:
BOOLRBS_DMM_UnuseHMem ( hMEM hMem )
Parameters[in] hMem handleofaallocatedmemory.
Returnsmemoryareapointer.
SeealsoRBS_DMM_UseHMem()
NoteusedinpairwithRBS_DMM_UseHMem()
Hereisthecallgraphforthisfunction:
Hereisthecallergraphforthisfunction:
![Page 108: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/108.jpg)
void*RBS_DMM_UseHBlock ( hBLOCK hBlock )
Parameters[in] hBlock handleofaallocatedblock.
Returnsblockareapointer.
SeealsoRBS_DMM_UnuseHBlock()
NoteusedinpairwithRBS_DMM_UnuseHBlock()
Hereisthecallgraphforthisfunction:
Hereisthecallergraphforthisfunction:
void*RBS_DMM_UseHMem ( hMEM hMem )
Parameters[in] hMem handleofaallocatedmemory.
Returnsmemoryareapointer.
SeealsoRBS_DMM_UnuseHMem()
![Page 109: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/109.jpg)
NoteusedinpairwithRBS_DMM_UnuseHMem()
Hereisthecallgraphforthisfunction:
Hereisthecallergraphforthisfunction:
Generatedby 1.8.9.1
![Page 110: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/110.jpg)
DataStructures|Macros|Typedefs
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
protothreadprocess
![Page 111: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/111.jpg)
DataStructuresstruct process_struct Processstructure(oneprocessconsistsoneprotothread).
More...
![Page 112: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/112.jpg)
Macros#define PROCESS_NONENULL#define PROCESS_BROADCASTNULL
![Page 113: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/113.jpg)
TypedefstypedefU8 process_event_t
typedefvoid* process_data_t
typedefstructprocess_struct tPROCESS Processstructure(oneprocessconsists
oneprotothread).More...
![Page 114: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/114.jpg)
predefinedeventtype#define PROCESS_EVENT_NONE0x80#define PROCESS_EVENT_INIT0x81#define PROCESS_EVENT_POLL0x82#define PROCESS_EVENT_EXIT0x83#define PROCESS_EVENT_SERVICE_REMOVED0x84#define PROCESS_EVENT_CONTINUE0x85#define PROCESS_EVENT_MSG0x86#define PROCESS_EVENT_EXITED0x87#define PROCESS_EVENT_TIMER0x88#define PROCESS_EVENT_COM0x89#define PROCESS_EVENT_MAX0x8a
![Page 115: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/115.jpg)
processdeclarationanddefinition#define PROCESS_THREAD(name,ev,data) Definethebodyofaprocess.More...#define PROCESS_NAME(name)externtPROCESSname Declarethenameofaprocess.More...#define PROCESS(name,strname) Defineaprocess.More...
![Page 116: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/116.jpg)
semaphoredeclarationanddefinition#define SEM_NAME(name)externstructpt_semsem_##name Declarethenameofasemaphore.More...#define SEM(name,count) Defineasemaphore.More...
![Page 117: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/117.jpg)
processprotothreadfunctions#define PROCESS_BEGIN() Definethebeginningofaprocess.More...#define PROCESS_END() Definetheendofaprocess.More...#define PROCESS_WAIT_EVENT() Waitforaneventtobepostedtotheprocess.More...#define PROCESS_WAIT_EVENT_UNTIL(c) Waitforaneventtobepostedtotheprocess,withanextra
condition.More...#define PROCESS_YIELD() Yieldthecurrentlyrunningprocess.#define PROCESS_YIELD_UNTIL(c) Yieldthecurrentlyrunningprocessuntilaconditionoccurs.
More...#define PROCESS_WAIT_UNTIL(c) Waitforaconditiontooccur.More...#define PROCESS_WAIT_WHILE(c) Waitforaconditionnotoccur.More...#define PROCESS_EXIT() Exitthecurrentlyrunningprocess.#define PROCESS_PT_SPAWN(pt,thread) Spawnaprotothreadfromtheprocess.More...#define PROCESS_PAUSE()
![Page 118: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/118.jpg)
Yieldtheprocessforashortwhile.More...#define PROCESS_WAIT_SEM(name)#define PROCESS_SIGNAL_SEM(name)
![Page 119: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/119.jpg)
pollandexithandlers
#define PROCESS_POLLHANDLER(handler)if(ev==PROCESS_EVENT_POLL){handler;} Specifyanactionwhenaprocessispolled.More...
#define PROCESS_EXITHANDLER(handler)if(ev==PROCESS_EVENT_EXIT){handler;} Specifyanactionwhenaprocessexits.More...
![Page 120: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/120.jpg)
processfunctionscalledfromapplicationprogramstPROCESS* process_current
BOOL process_start(tPROCESS*ptProcess,process_data_targ) Startaprocess.More...
BOOL process_post(tPROCESS*ptProcess,process_event_tev,void*data)
Postanasynchronouseventtooneorallprocesses.More...
void process_send(tPROCESS*ptProcess,process_event_tev,void*data) Sendasynchronouseventtoaprocess.More...
void process_exit(tPROCESS*ptProcess) Causeaprocesstoexit.More...process_event_t process_alloc_event(void) Allocateaglobaleventnumber.More...
#define PROCESS_CURRENT()process_current Getapointertothecurrentlyrunningprocess.More...
#definePROCESS_CONTEXT_BEGIN(ptProcess){tPROCESS*tmp_current=PROCESS_CURRENT();process_current=ptProcess
Switchcontexttoanotherprocess.More...
#define PROCESS_CONTEXT_END(ptProcess)process_current=tmp_current;} Endacontextswitch.More...
![Page 121: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/121.jpg)
processfunctionscalledfromdevicedrivers.BOOL process_poll(tPROCESS*ptProcess) Requestaprocesstobepolled.More...
![Page 122: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/122.jpg)
functionscalledbythesystemandboot-upcodeU16 process_run(void)
Runthesystemonce-callpollhandlersandprocessoneevent.More...
BOOL process_is_running(tPROCESS*ptProcess) Checkifaprocessisrunning.More...
U16 process_nevents(void) Numberofeventswaitingtobeprocessed.More...
![Page 123: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/123.jpg)
DetailedDescription
Aprocessinconsistsofasingleprotothread.
![Page 124: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/124.jpg)
MacroDefinitionDocumentation
#definePROCESS ( name, strname)
Thismacrodefinesaprocess.Theprocesshastwonames:thevariableoftheprocessstructure,whichisusedbytheCprogram,andahumanreadablestringname,whichisusedwhendebugging.AconfigurationoptionallowsremovalofthereadablenametosaveRAM.
Parameters[in] name Thevariablenameoftheprocessstructure.[in] strname Thestringrepresentationoftheprocess'name.
Notedefinitionmustbeglobal.
#definePROCESS_BEGIN ( )
Thismacrodefinesthebeginningofaprocess,andmustalwaysappearinaPROCESS_THREAD()definition.ThePROCESS_END()macromustcomeattheendoftheprocess.
#definePROCESS_CONTEXT_BEGIN ( ptProcess )
{tPROCESS*tmp_current=PROCESS_CURRENT();process_current=ptProcess
Thisfunctionswitchcontexttothespecifiedprocessandexecutesthecodeasifrunbythatprocess.Typicaluseofthisfunctionistoswitchcontextinservices,calledbyotherprocesses.EachPROCESS_CONTEXT_BEGIN()mustbefollowedbythe
![Page 125: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/125.jpg)
PROCESS_CONTEXT_END()macrotoendthecontextswitch.
Parameters[in] ptProcess Theprocesstouseascontext
SeealsoPROCESS_CONTEXT_END()PROCESS_CURRENT()
Example:
1 PROCESS_CONTEXT_BEGIN(&test_process);
2 etimer_set(&timer,CLOCK_SECOND);
3 PROCESS_CONTEXT_END(&test_process);
#definePROCESS_CONTEXT_END ( ptProcess )
process_current=tmp_current;}
Thisfunctionendsacontextswitchandchangesbacktothepreviousprocess.
Parameters[in] ptProcess Theprocessusedinthecontextswitch
SeealsoPROCESS_CONTEXT_START()
#definePROCESS_CURRENT ( ) process_current
Thismacrogetapointertothecurrentlyrunningprocess.Typically,thismacroisusedtopostaneventtothecurrentprocesswithprocess_post().
#definePROCESS_END ( )
Thismacrodefinestheendofaprocess.Itmustappearina
![Page 126: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/126.jpg)
PROCESS_THREAD()definitionandmustalwaysbeincluded.TheprocessexitswhenthePROCESS_END()macroisreached.
#definePROCESS_EXITHANDLER ( handler )
if(ev==PROCESS_EVENT_EXIT){handler;}
NoteThisdeclarationmustcomeimmediatelybeforethePROCESS_BEGIN()macro.
Parametershandler Theactiontobeperformed.
#definePROCESS_NAME ( name ) externtPROCESSname
ThismacroistypicallyusedinheaderfilestodeclarethenameofaprocessthatisimplementedintheCfile.
#definePROCESS_PAUSE ( )
Thismacroyieldsthecurrentlyrunningprocessforashortwhile,thuslettingotherprocessesrunbeforetheprocesscontinues.
#definePROCESS_POLLHANDLER ( handler )
if(ev==PROCESS_EVENT_POLL){handler;}
NoteThisdeclarationmustcomeimmediatelybeforethePROCESS_BEGIN()macro.
Parametershandler Theactiontobeperformed.
![Page 127: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/127.jpg)
#definePROCESS_PT_SPAWN ( pt, thread)
Parameterspt[inout] Theprotothreadstate(structpt)forthenew
protothreadthread[in] Thecalltotheprotothreadfunction.
SeealsoPT_SPAWN()
#definePROCESS_SIGNAL_SEM ( name )
Signalasemaphore
Thismacrocarriesoutthe"signal"operationonthesemaphore.
Parameters[in] name semaphorename
NoteIt'stheapplication'sresponsibilitytonotifythewaitingprocessifsemaphoreisavilable.
SeealsoPROCESS_WAIT_SEM()
#definePROCESS_THREAD ( name, ev, data)
Thismacroisusedtodefinethebody(protothread)ofaprocess.The
![Page 128: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/128.jpg)
processiscalledwheneveraneventoccursinthesystem,AprocessalwaysstartwiththePROCESS_BEGIN()macroandendwiththePROCESS_END()macro.
#definePROCESS_WAIT_EVENT ( )
Thismacroblocksthecurrentlyrunningprocessuntiltheprocessreceivesanevent.
#definePROCESS_WAIT_EVENT_UNTIL ( c )
ThismacroissimilartoPROCESS_WAIT_EVENT()inthatitblocksthecurrentlyrunningprocessuntiltheprocessreceivesanevent.ButPROCESS_WAIT_EVENT_UNTIL()takesanextraconditionwhichmustbetruefortheprocesstocontinue.
Parameters[in] c Theconditionthatmustbetruefortheprocessto
continue.
SeealsoPT_WAIT_UNTIL()
#definePROCESS_WAIT_SEM ( name )
Waitforasemaphore
Thismacrocarriesoutthe"wait"operationonthesemaphore.
Parameters[in] name semaphorename
NoteIt'stheapplication'sresponsibilitytonotifythewaitingprocessifsemaphoreisavilable.
![Page 129: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/129.jpg)
SeealsoPROCESS_SIGNAL_SEM()
#definePROCESS_WAIT_UNTIL ( c )
Thismacrodoesnotguaranteethattheprocessyields,andshouldthereforebeusedwithcare.Inmostcases,PROCESS_WAIT_EVENT(),PROCESS_WAIT_EVENT_UNTIL(),PROCESS_YIELD()orPROCESS_YIELD_UNTIL()shouldbeusedinstead.
Parameters[in] c Theconditionthatmustbetruefortheprocessto
continue
#definePROCESS_WAIT_WHILE ( c )
Thismacrodoesnotguaranteethattheprocessyields,andshouldthereforebeusedwithcare.Inmostcases,PROCESS_WAIT_EVENT(),PROCESS_WAIT_EVENT_UNTIL(),PROCESS_YIELD()orPROCESS_YIELD_UNTIL()shouldbeusedinstead.
Parameters[in] c Theconditionthatmustbefalsefortheprocessto
continue.
#definePROCESS_YIELD_UNTIL ( c )
ThismacroisdifferentfromPROCESS_WAIT_UNTIL()inthatPROCESS_YIELD_UNTIL()isguaranteedtoalwaysyieldatleastonce.ThisensuresthattheprocessdoesnotendupinaninfiniteloopandmonopolizingtheCPU.
Parameters
![Page 130: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/130.jpg)
[in] c Theconditiontowaitfor.
#defineSEM ( name, count)
Parametersname Thevariablenameofthesemaphorestructure.count Thecountvalueofthesemaphore.
Notedefinitionmustbeglobal.
#defineSEM_NAME ( name ) externstructpt_semsem_##name
ThismacroistypicallyusedinheaderfilestodeclarethenameofasemaphorethatisimplementedintheCfile.
![Page 131: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/131.jpg)
TypedefDocumentation
typedefstructprocess_structtPROCESS
Noteapplicationcodeshouldnotchangeanymemberoftheprocessstructurefortheyaremaintainedbysysteminside.
![Page 132: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/132.jpg)
FunctionDocumentation
process_event_tprocess_alloc_event ( void )
eventnumbersabove128areglobalandmaybepostedfromoneprocesstoanother.Thisfunctionallocatesonesucheventnumber.
NoteTherecurrentlyisnowaytodeallocateanallocatedeventnumber.
ReturnsTheallocatedeventnumber
voidprocess_exit ( tPROCESS* ptProcess )
Thisfunctioncausesaprocesstoexit.Theprocesscaneitherbethecurrentlyexecutingprocess,oranotherprocessthatiscurrentlyrunning.
Parameters[in,out] ptProcess Theprocessthatistobeexited
SeealsoPROCESS_CURRENT()
BOOLprocess_is_running ( tPROCESS* ptProcess )
Thisfunctionchecksifaspecificprocessisrunning.Aprocesscanbeonrunningstateaftercallingprocess_start()normally.
Parameters[in] ptProcess Theprocesspointer.
![Page 133: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/133.jpg)
ReturnvaluesTRUE iftheprocessisrunning.FALSE iftheprocessisnotrunning.
Hereisthecallergraphforthisfunction:
U16process_nevents ( void )
ReturnsNumberofeventsthatarecurrentlywaitingtobeprocessed.
BOOLprocess_poll ( tPROCESS* ptProcess )
Thisfunctiontypicallyiscalledfromaninterrupthandlertocauseaprocesstobepolled.
Parameters[in,out] ptProcess Apointertotheprocess'processstructure.
ReturnvaluesTRUE pollsuccessfully.FALSE iftheprocessisnotrunning.
Hereisthecallgraphforthisfunction:
Hereisthecallergraphforthisfunction:
BOOLprocess_post ( tPROCESS* ptProcess,process_event_t ev,void* data
![Page 134: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/134.jpg)
)
Thisfunctionpostsanasynchronouseventtooneorallprocesses.Thehandingoftheeventisdeferreduntilthetargetprocessisscheduledbythekernel.Aneventcanbebroadcasttoallprocesses,inwhichcaseallprocessesinthesystemwillbescheduledtohandletheevent.
Parameters[in,out] ptProcess Theprocesstowhichtheeventshouldbe
posted,orPROCESS_BROADCASTiftheeventshouldbepostedtoallprocesses.
[in] ev Theeventtobeposted.[in,out] data Theauxiliarydatatobesentwiththeevent
ReturnvaluesTRUE Theeventcouldbeposted.FALSE Theeventqueuewasfullandtheeventcouldnotbe
posted.
Seealsoprocess_send()
U16process_run ( void )
Thisfunctionshouldbecalledrepeatedlyfromthemain()programtoactuallyrunthesystem.Itcallsthenecessarypollhandlers,andprocessesoneevent.ThefunctionreturnsthenumberofeventsthatarewaitingintheeventqueuesothatthecallermaychoosetoputtheCPUtosleepwhentherearenopendingevents.
Exampleabouthowtouseprotothreadprocessmodelforevent-drivensystem:
1 intmain(void){
2 RBS_Init();//RBSinitialization
3 process_start();//startprocess
![Page 135: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/135.jpg)
4 ...
5 while(1){
6 do{
7 ...//dosomeoptionalusercode
8 }while(process_run()>0);
9 sleep();//gotosleep
10 }
11 }
ReturnsThenumberofeventsthatarecurrentlywaitingtobeprocessed.
voidprocess_send ( tPROCESS* ptProcess,process_event_t ev,void* data)
Thisfunctionsendsasynchronouseventtooneprocesses.Onoppositeofprocess_post(),thehandingoftheeventiscompletedimmediatelyaftercalling.
Parameters[in,out] ptProcess Apointertotheprocess'processstructure.[in] ev Theeventtobeposted.[in,out] data Apointertoadditionaldatathatisposted
togetherwiththeevent.
Seealsoprocess_post()
Hereisthecallergraphforthisfunction:
BOOLprocess_start ( tPROCESS* ptProcess,process_data_t arg
![Page 136: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/136.jpg)
)
Parameters[in,out] ptProcess Apointertoaprocessstructure.[in] arg Anargumentpointerthatcanbepassedto
thenewprocess
ReturnvaluesTRUE successful.FALSE Trytostartaprocessthatisalreadyrunning.
Hereisthecallgraphforthisfunction:
Hereisthecallergraphforthisfunction:
Generatedby 1.8.9.1
![Page 137: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/137.jpg)
PublicMemberFunctions|DataFields
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
process_structStructReferenceprotothreadprocess
Processstructure(oneprocessconsistsoneprotothread).More...
#include<RainbowBS.h>
Collaborationdiagramforprocess_struct:
![Page 138: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/138.jpg)
PublicMemberFunctions PT_THREAD((*thread)(structpt*,process_event_t,process_data_t))
![Page 139: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/139.jpg)
DataFieldsstructprocess_struct* next
constchar* name
structpt pt
U8 state
BOOL needspoll
![Page 140: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/140.jpg)
DetailedDescription
Noteapplicationcodeshouldnotchangeanymemberoftheprocessstructurefortheyaremaintainedbysysteminside.
![Page 141: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/141.jpg)
FieldDocumentation
constchar*name
processnamestring
BOOLneedspoll
indicateifaprocesshashighprivilegetobecalled,
Seealsoprocess_poll()
structprocess_struct*next
pointertothenextprocess,allprocessesareinaprocesslist
U8state
indicateprocessstate
Thedocumentationforthisstructwasgeneratedfromthefollowingfile:
RainbowBS.h
Generatedby 1.8.9.1
![Page 143: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/143.jpg)
DataStructuresstruct etime_struct Eventtimerstructure.More...
![Page 144: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/144.jpg)
Typedefstypedefstructetime_struct tETIME Eventtimerstructure.More...
![Page 145: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/145.jpg)
etimerfunctionscalledfromapplicationprogramsvoid etimer_set(tETIME*ptEtime,TICKinterval)
Setaneventtimer.More...
void etimer_reset(tETIME*ptEtime) Resetaneventtimerwiththesameintervalaswaspreviously
set.More...
void etimer_restart(tETIME*ptEtime) Restartaneventtimerfromthecurrentpointintime.More...
void etimer_adjust(tETIME*ptEtime,inttimediff) Adjusttheexpirationtimeforaneventtimer.More...TICK etimer_expiration_time(tETIME*ptEtime) Gettheexpirationtimefortheeventtimer.More...TICK etimer_start_time(tETIME*ptEtime) Getthestarttimefortheeventtimer.More...BOOL etimer_expired(tETIME*ptEtime) Checkifaneventtimerhasexpired.More...
void etimer_stop(tETIME*ptEtime) Stopapendingeventtimer.More...
![Page 146: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/146.jpg)
etimerfunctionscalledfromtimerinterrupts,bythesystem
void etimer_request_poll(void) Maketheeventtimerawarethattheclockhaschanged.More...BOOL etimer_pending(void) Checkifthereareanynon-expiredeventtimers.More...
![Page 147: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/147.jpg)
DetailedDescription
Eventtimersprovidesawaytogeneratetimedevents.Aneventtimerwillpostaneventtotheprocessthatsetthetimerwhentheeventtimerexpires.
Aneventtimerisdeclaredasastructetimerandallaccesstotheeventtimerismadebyapointertothedeclaredeventtimer.
![Page 148: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/148.jpg)
TypedefDocumentation
typedefstructetime_structtETIME
Thisstructureisusedfordeclaringatimer.Thetimermustbesetwithetimer_set()beforeitcanbeused.
![Page 149: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/149.jpg)
FunctionDocumentation
voidetimer_adjust ( tETIME* ptEtime,int timediff)
Thisfunctionisusedtoadjustthetimetheeventtimerwillexpire.Itcanbeusedtosynchronizeperiodictimerswithouttheneedtorestartthetimerorchangethetimerinterval.
Parameters[in,out] ptEtime Apointertotheeventtimer.[in] timediff Thetimedifferencetoadjusttheexpiration
timewith.
NoteThisfunctionshouldonlybeusedforsmalladjustments.Forlargeadjustmentsuseetimer_set()instead.Aperiodictimerwilldriftunlesstheetimer_reset()functionisused.
Seealsoetimer_set()etimer_reset()
TICKetimer_expiration_time ( tETIME* ptEtime )
Thisfunctionreturnstheexpirationtimeforaneventtimer.
Parameters[in,out] ptEtime Apointertotheeventtimer.
Returns
![Page 150: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/150.jpg)
Theexpirationtimefortheeventtimer.
BOOLetimer_expired ( tETIME* ptEtime )
Thisfunctiontestsifaneventtimerhasexpiredandreturnstrueorfalsedependingonitsstatus.
Parameters[in] ptEtime Apointertotheeventtimer.
ReturnvaluesTRUE ifthetimerhasexpired.FALSE ifthetimerhasnotexpired.
BOOLetimer_pending ( void )
Thisfunctionchecksifthereareanyactiveeventtimersthathavenotexpired.
ReturnvaluesTRUE ifthereareactiveeventtimers.FALSE iftherearenoactivetimers.
voidetimer_request_poll ( void )
Thisfunctionisusedtoinformtheeventtimermodulethatthesystemclockhasbeenupdated.Typically,thisfunctionwouldbecalledfromthetimerinterrupthandlerwhentheclockhasticked.
Hereisthecallgraphforthisfunction:
voidetimer_reset ( tETIME* ptEtime )
![Page 151: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/151.jpg)
Thisfunctionresetstheeventtimerwiththesameintervalthatwasgiventotheeventtimerwiththeetimer_set()function.Thestartpointoftheintervalistheexacttimethattheeventtimerlastexpired.Therefore,thisfunctionwillcausethetimertobestableovertime,unliketheetimer_restart()function.
Parameters[in,out] ptEtime Apointertotheeventtimer.
Seealsoetimer_restart()
voidetimer_restart ( tETIME* ptEtime )
Thisfunctionrestartstheeventtimerwiththesameintervalthatwasgiventotheetimer_set()function.Theeventtimerwillstartatthecurrenttime.
Parameters[in,out] ptEtime Apointertotheeventtimer.
NoteAperiodictimerwilldriftifthisfunctionisusedtoresetit.Forperiodictimers,usetheetimer_reset()functioninstead.
Seealsoetimer_reset()
Hereisthecallgraphforthisfunction:
voidetimer_set ( tETIME* ptEtime,TICK interval)
Thisfunctionisusedtosetaneventtimerforatimesometimeinthe
![Page 152: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/152.jpg)
future.Whentheeventtimerexpires,theeventPROCESS_EVENT_TIMERwillbepostedtotheprocessthatcalledtheetimer_set()function.
Parameters[in,out] ptEtime Apointertotheeventtimer[in] interval Theintervalbeforethetimerexpires.
Hereisthecallgraphforthisfunction:
TICKetimer_start_time ( tETIME* ptEtime )
Thisfunctionreturnsthestarttime(whenthetimerwaslastset)foraneventtimer.
Parameters[in,out] ptEtime Apointertotheeventtimer
ReturnsThestarttimefortheeventtimer.
voidetimer_stop ( tETIME* ptEtime )
Thisfunctionstopsaneventtimerthathaspreviouslybeensetwithetimer_set()oretimer_reset().Afterthisfunctionhasbeencalled,theeventtimerwillnotemitanyeventwhenitexpires.
Parameters[in,out] ptEtime Apointertothependingeventtimer.
Generatedby 1.8.9.1
![Page 153: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/153.jpg)
DataFields
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
etime_structStructReferenceEventtimers
Eventtimerstructure.More...
#include<RainbowBS.h>
Collaborationdiagramforetime_struct:
![Page 154: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/154.jpg)
DataFieldsTICK start
TICK interval
structetime_struct* next
tPROCESS* p
![Page 155: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/155.jpg)
DetailedDescription
Thisstructureisusedfordeclaringatimer.Thetimermustbesetwithetimer_set()beforeitcanbeused.
Thedocumentationforthisstructwasgeneratedfromthefollowingfile:
RainbowBS.h
Generatedby 1.8.9.1
![Page 157: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/157.jpg)
statementmacros
statementmacrosfordebug
#define RBS_DEBUG_STA(sta)sta Cstatementstaiscompiledifenabledebug.More...#define RBS_DEBUG_IF(exp,sta)if(exp){sta Cstatementifiscompiledifenabledebug.More...
#define RBS_DEBUG_ELSIF(sta1,exp,sta2)sta1;}elseif(exp){sta2 Cstatementelseifiscompiledifenabledebug.More...#define RBS_DEBUG_ENDIF(sta)sta;} Cstatement}forifiscompiledifenabledebug.More...
![Page 158: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/158.jpg)
errormacrofunction
errormacrosfordebugoutput
#define RBS_DEBUG_ERROR(exp,s,sta) Outputerrorinformation.More...#define RBS_DEBUG_ERROR_FORMAT(exp,format,sta,...) Outputformaterrorinformationconditionally.More...
![Page 159: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/159.jpg)
warningmacrofunction
warningmacrosfordebugoutput
#define RBS_DEBUG_WARN(exp,s) Outputwarninginformationconditionally.More...#define RBS_DEBUG_WARN_FORMAT(exp,format,...) Outputformatwarninginformationconditionally.More...
![Page 160: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/160.jpg)
logmacrofunction
logmacrosfordebugoutput
#define RBS_DEBUG_LOG(s) Outputformatloginformation.More...#define RBS_DEBUG_LOG_FORMAT(format,...) Outputformatloginformation.More...
![Page 161: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/161.jpg)
DetailedDescription
usedforsystemorapplicationdebug.
![Page 162: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/162.jpg)
MacroDefinitionDocumentation
#defineRBS_DEBUG_ELSIF ( sta1, exp, sta2) sta1;}elseif(exp){sta2
Thismacroequalstosta1;}elseif(exp){sta2
Parameterssta1Cstatement.exp Cexpression.sta2Cstatement.
NotethisshouldusedwithRBS_DEBUG_IF()andRBS_DEBUG_ENDIF().
SeealsoRBS_DEBUG_IF()RBS_DEBUG_ENDIF()
#defineRBS_DEBUG_ENDIF ( sta ) sta;}
Thismacroequalstosta1;}
ParametersstaCstatement.
NotethisshouldusedwithRBS_DEBUG_IF()andRBS_DEBUG_ELSIF().
SeealsoRBS_DEBUG_IF()
![Page 163: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/163.jpg)
RBS_DEBUG_ELSIF()
#defineRBS_DEBUG_ERROR ( exp, s, sta)
Parameters[in] exp Clanguagelogicalexpression.[in] s informationstring.[in] sta Cstatement.
NotelengthofinformationstringshouldnotexceedRBS_CFG_DEBUG_BUFSIZE
#defineRBS_DEBUG_ERROR_FORMAT ( exp, format, sta, ...)
Parameters[in] exp Clanguagelogicalexpression.[in] format formatinformationstring.[in] sta Cstatement.[in] ... parameters.
NotelengthofinformationstringshouldnotexceedRBS_CFG_DEBUG_BUFSIZE
#defineRBS_DEBUG_IF ( exp,
![Page 164: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/164.jpg)
sta) if(exp){sta
Thismacroequalstoif(exp){sta
Parametersexp Cexpression.sta Cstatement.
NotethisshouldusedwithRBS_DEBUG_ELSIF()andRBS_DEBUG_ENDIF().
SeealsoRBS_DEBUG_ELSIF()RBS_DEBUG_ENDIF()
#defineRBS_DEBUG_LOG ( s )
Parameters[in] s informationstring.
NotelengthofinformationstringshouldnotexceedRBS_CFG_DEBUG_BUFSIZE
#defineRBS_DEBUG_LOG_FORMAT ( format, ...)
Parameters[in] format formatinformationstring.[in] ... parameters.
Notelengthofinformationstringshouldnotexceed
![Page 165: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/165.jpg)
RBS_CFG_DEBUG_BUFSIZE
#defineRBS_DEBUG_STA ( sta ) sta
ParametersstaCstatement
#defineRBS_DEBUG_WARN ( exp, s)
Parameters[in] exp Clanguagelogicalexpression.[in] s informationstring.
NotelengthofinformationstringshouldnotexceedRBS_CFG_DEBUG_BUFSIZE
#defineRBS_DEBUG_WARN_FORMAT ( exp, format, ...)
Parameters[in] exp Clanguagelogicalexpression.[in] format formatinformationstring.[in] ... parameters.
NotelengthofinformationstringshouldnotexceedRBS_CFG_DEBUG_BUFSIZE
![Page 167: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/167.jpg)
Modules|Files|DataStructures|Macros
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
Pt
CollaborationdiagramforPt:
![Page 168: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/168.jpg)
Modules Localcontinuations Protothreadsemaphores
![Page 169: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/169.jpg)
Filesfile pt.h
![Page 170: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/170.jpg)
DataStructuresstruct pt
![Page 171: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/171.jpg)
Macros#define PT_WAITING0#define PT_YIELDED1#define PT_EXITED2#define PT_ENDED3
![Page 172: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/172.jpg)
Initialization#define PT_INIT(pt)
![Page 173: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/173.jpg)
Declarationanddefinition#define PT_THREAD(name_args)#define PT_BEGIN(pt)#define PT_END(pt)
![Page 174: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/174.jpg)
Blockedwait#define PT_WAIT_UNTIL(pt,condition)#define PT_WAIT_WHILE(pt,cond)
![Page 175: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/175.jpg)
Hierarchicalprotothreads#define PT_WAIT_THREAD(pt,thread)#define PT_SPAWN(pt,child,thread)
![Page 176: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/176.jpg)
Exitingandrestarting#define PT_RESTART(pt)#define PT_EXIT(pt)
![Page 177: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/177.jpg)
Callingaprotothread#define PT_SCHEDULE(f)
![Page 178: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/178.jpg)
Yieldingfromaprotothread#define PT_YIELD(pt)#define PT_YIELD_UNTIL(pt,cond) Yieldfromtheprotothreaduntilaconditionoccurs.More...
![Page 179: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/179.jpg)
DetailedDescription
MacroDefinitionDocumentation
#definePT_BEGIN ( pt )
DeclarethestartofaprotothreadinsidetheCfunctionimplementingtheprotothread.
Thismacroisusedtodeclarethestartingpointofaprotothread.Itshouldbeplacedatthestartofthefunctioninwhichtheprotothreadruns.AllCstatementsabovethePT_BEGIN()invokationwillbeexecutedeachtimetheprotothreadisscheduled.
Parameterspt Apointertotheprotothreadcontrolstructure.
#definePT_END ( pt )
Declaretheendofaprotothread.
Thismacroisusedfordeclaringthataprotothreadends.ItmustalwaysbeusedtogetherwithamatchingPT_BEGIN()macro.
Parameterspt Apointertotheprotothreadcontrolstructure.
#definePT_EXIT ( pt )
Exittheprotothread.
![Page 180: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/180.jpg)
Thismacrocausestheprotothreadtoexit.Iftheprotothreadwasspawnedbyanotherprotothread,theparentprotothreadwillbecomeunblockedandcancontinuetorun.
Parameterspt Apointertotheprotothreadcontrolstructure.
#definePT_INIT ( pt )
Initializeaprotothread.
Initializesaprotothread.Initializationmustbedonepriortostartingtoexecutetheprotothread.
Parameterspt Apointertotheprotothreadcontrolstructure.
SeealsoPT_SPAWN()
#definePT_RESTART ( pt )
Restarttheprotothread.
ThismacrowillblockandcausetherunningprotothreadtorestartitsexecutionattheplaceofthePT_BEGIN()call.
Parameterspt Apointertotheprotothreadcontrolstructure.
#definePT_SCHEDULE ( f )
Scheduleaprotothread.
Thisfunctionshedulesaprotothread.Thereturnvalueofthefunctionisnon-zeroiftheprotothreadisrunningorzeroiftheprotothreadhas
![Page 181: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/181.jpg)
exited.
Parametersf ThecalltotheCfunctionimplementingtheprotothreadtobescheduled
#definePT_SPAWN ( pt, child, thread)
Spawnachildprotothreadandwaituntilitexits.
Thismacrospawnsachildprotothreadandwaitsuntilitexits.Themacrocanonlybeusedwithinaprotothread.
Parameterspt Apointertotheprotothreadcontrolstructure.child Apointertothechildprotothread'scontrolstructure.thread Thechildprotothreadwitharguments
#definePT_THREAD ( name_args )
Declarationofaprotothread.
Thismacroisusedtodeclareaprotothread.Allprotothreadsmustbedeclaredwiththismacro.
Parametersname_args ThenameandargumentsoftheCfunction
implementingtheprotothread.
#definePT_WAIT_THREAD ( pt, thread)
![Page 182: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/182.jpg)
Blockandwaituntilachildprotothreadcompletes.
Thismacroschedulesachildprotothread.Thecurrentprotothreadwillblockuntilthechildprotothreadcompletes.
NoteThechildprotothreadmustbemanuallyinitializedwiththePT_INIT()functionbeforethisfunctionisused.
Parameterspt Apointertotheprotothreadcontrolstructure.thread Thechildprotothreadwitharguments
SeealsoPT_SPAWN()
#definePT_WAIT_UNTIL ( pt, condition)
Blockandwaituntilconditionistrue.
Thismacroblockstheprotothreaduntilthespecifiedconditionistrue.
Parameterspt Apointertotheprotothreadcontrolstructure.condition Thecondition.
#definePT_WAIT_WHILE ( pt, cond)
Blockandwaitwhileconditionistrue.
Thisfunctionblocksandwaitswhileconditionistrue.See
![Page 183: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/183.jpg)
PT_WAIT_UNTIL().
Parameterspt Apointertotheprotothreadcontrolstructure.cond Thecondition.
#definePT_YIELD ( pt )
Yieldfromthecurrentprotothread.
Thisfunctionwillyieldtheprotothread,therebyallowingotherprocessingtotakeplaceinthesystem.
Parameterspt Apointertotheprotothreadcontrolstructure.
#definePT_YIELD_UNTIL ( pt, cond)
Parameterspt Apointertotheprotothreadcontrolstructure.cond Thecondition.
Thisfunctionwillyieldtheprotothread,untilthe
specifiedconditionevaluatestotrue.
Generatedby 1.8.9.1
![Page 184: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/184.jpg)
Files|Macros|Typedefs
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
LocalcontinuationsPt
CollaborationdiagramforLocalcontinuations:
![Page 185: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/185.jpg)
Filesfile lc-addrlabels.hfile lc-switch.hfile lc.h
![Page 186: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/186.jpg)
Macros#define LC_INIT(s)s=NULL#define LC_RESUME(s)#define LC_CONCAT2(s1,s2)s1##s2#define LC_CONCAT(s1,s2)LC_CONCAT2(s1,s2)#define LC_SET(s)#define LC_END(s)#define LC_INIT(s)s=0;#define LC_RESUME(s)switch(s){case0:#define LC_SET(s)s=__LINE__;case__LINE__:#define LC_END(s)}#define __LC_H__
![Page 187: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/187.jpg)
Typedefstypedefvoid* lc_t
typedefunsignedshort lc_t
![Page 188: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/188.jpg)
DetailedDescription
Localcontinuationsformthebasisforimplementingprotothreads.Alocalcontinuationcanbesetinaspecificfunctiontocapturethestateofthefunction.Afteralocalcontinuationhasbeensetcanberesumedinordertorestorethestateofthefunctionatthepointwherethelocalcontinuationwasset.
![Page 189: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/189.jpg)
MacroDefinitionDocumentation
#defineLC_RESUME ( s )
Value:do{\
if(s!=NULL){\
goto*s;\
}\
}while(0)
#defineLC_SET ( s )
Value:do{\
LC_CONCAT(LC_LABEL,__LINE__):\
(s)=&&LC_CONCAT(LC_LABEL,__LINE__);\
}while(0)
Generatedby 1.8.9.1
![Page 190: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/190.jpg)
RainbowBS RBSSource Base Protothreads
Macros|Typedefs
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
lc-addrlabels.hFileReferencePt»Localcontinuations
![Page 191: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/191.jpg)
Macros#define LC_INIT(s)s=NULL#define LC_RESUME(s)#define LC_CONCAT2(s1,s2)s1##s2#define LC_CONCAT(s1,s2)LC_CONCAT2(s1,s2)#define LC_SET(s)#define LC_END(s)
![Page 192: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/192.jpg)
Typedefstypedefvoid* lc_t
![Page 193: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/193.jpg)
DetailedDescription
Implementationoflocalcontinuationsbasedonthe"Labelsasvalues"featureofgcc
ThisimplementationoflocalcontinuationsisbasedonaspecialfeatureoftheGCCCcompilercalled"labelsasvalues".ThisfeatureallowsassigningpointerswiththeaddressofthecodecorrespondingtoaparticularClabel.
Formoreinformation,seetheGCCdocumentation:http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
Generatedby 1.8.9.1
![Page 194: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/194.jpg)
RainbowBS RBSSource Base Protothreads
Macros|Typedefs
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
lc-switch.hFileReferencePt»Localcontinuations
Thisgraphshowswhichfilesdirectlyorindirectlyincludethisfile:
![Page 195: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/195.jpg)
Macros#define LC_INIT(s)s=0;#define LC_RESUME(s)switch(s){case0:#define LC_SET(s)s=__LINE__;case__LINE__:#define LC_END(s)}
![Page 196: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/196.jpg)
Typedefstypedefunsignedshort lc_t
![Page 197: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/197.jpg)
DetailedDescription
Implementationoflocalcontinuationsbasedonswitch()statment
ThisimplementationoflocalcontinuationsusestheCswitch()statementtoresumeexecutionofafunctionsomewhereinsidethefunction'sbody.Theimplementationisbasedonthefactthatswitch()statementsareabletojumpdirectlyintothebodiesofcontrolstructuressuchasif()orwhile()statmenets.
ThisimplementationborrowsheavilyfromSimonTatham'scoroutinesimplementationinC:http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
Generatedby 1.8.9.1
![Page 198: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/198.jpg)
RainbowBS RBSSource Base Protothreads
Macros
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
lc.hFileReferencePt»Localcontinuations
#include"lc-switch.h"
Includedependencygraphforlc.h:
Thisgraphshowswhichfilesdirectlyorindirectlyincludethisfile:
![Page 199: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/199.jpg)
DetailedDescription
Localcontinuations
Generatedby 1.8.9.1
![Page 200: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/200.jpg)
Files|DataStructures|Macros
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
ProtothreadsemaphoresPt
CollaborationdiagramforProtothreadsemaphores:
![Page 201: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/201.jpg)
Filesfile pt-sem.h
![Page 202: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/202.jpg)
DataStructuresstruct pt_sem
![Page 203: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/203.jpg)
Macros#define PT_SEM_INIT(s,c)#define PT_SEM_WAIT(pt,s)#define PT_SEM_SIGNAL(pt,s)
![Page 204: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/204.jpg)
DetailedDescription
Thismoduleimplementscountingsemaphoresontopofprotothreads.Semaphoresareasynchronizationprimitivethatprovidetwooperations:"wait"and"signal".The"wait"operationchecksthesemaphorecounterandblocksthethreadifthecounteriszero.The"signal"operationincreasesthesemaphorecounterbutdoesnotblock.Ifanotherthreadhasblockedwaitingforthesemaphorethatissignalled,theblockedthreadwillbecomerunnableagain.
Semaphorescanbeusedtoimplementother,morestructured,synchronizationprimitivessuchasmonitorsandmessagequeues/boundedbuffers(seebelow).
Thefollowingexampleshowshowtheproducer-consumerproblem,alsoknownastheboundedbufferproblem,canbesolvedusingprotothreadsandsemaphores.Notesontheprogramfollowaftertheexample.
#include"pt-sem.h"
#defineNUM_ITEMS32
#defineBUFSIZE8
staticstructpt_semmutex,full,empty;
PT_THREAD(producer(structpt*pt))
{
staticintproduced;
PT_BEGIN(pt);
for(produced=0;produced<NUM_ITEMS;++produced)
{
PT_SEM_WAIT(pt,&full);
PT_SEM_WAIT(pt,&mutex);
add_to_buffer(produce_item());
PT_SEM_SIGNAL(pt,&mutex);
![Page 205: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/205.jpg)
PT_SEM_SIGNAL(pt,&empty);
}
PT_END(pt);
}
PT_THREAD(consumer(structpt*pt))
{
staticintconsumed;
PT_BEGIN(pt);
for(consumed=0;consumed<NUM_ITEMS;++consumed)
{
PT_SEM_WAIT(pt,&empty);
PT_SEM_WAIT(pt,&mutex);
consume_item(get_from_buffer());
PT_SEM_SIGNAL(pt,&mutex);
PT_SEM_SIGNAL(pt,&full);
}
PT_END(pt);
}
PT_THREAD(driver_thread(structpt*pt))
{
staticstructptpt_producer,pt_consumer;
PT_BEGIN(pt);
PT_SEM_INIT(&empty,0);
PT_SEM_INIT(&full,BUFSIZE);
PT_SEM_INIT(&mutex,1);
PT_INIT(&pt_producer);
PT_INIT(&pt_consumer);
PT_WAIT_THREAD(pt,producer(&pt_producer)&
consumer(&pt_consumer));
![Page 206: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/206.jpg)
PT_END(pt);
}
Theprogramusesthreeprotothreads:oneprotothreadthatimplementstheconsumer,onethreadthatimplementstheproducer,andoneprotothreadthatdrivesthetwootherprotothreads.Theprogramusesthreesemaphores:"full","empty"and"mutex".The"mutex"semaphoreisusedtoprovidemutualexclusionforthebuffer,the"empty"semaphoreisusedtoblocktheconsumeristhebufferisempty,andthe"full"semaphoreisusedtoblocktheproduceristhebufferisfull.
The"driver_thread"holdstwoprotothreadstatevariables,"pt_producer"and"pt_consumer".Itisimportanttonotethatboththesevariablesaredeclaredasstatic.Ifthestatickeywordisnotused,bothvariablesarestoredonthestack.Sinceprotothreadsdonotstorethestack,thesevariablesmaybeoverwrittenduringaprotothreadwaitoperation.Similarly,boththe"consumer"and"producer"protothreadsdeclaretheirlocalvariablesasstatic,toavoidthembeingstoredonthestack.
![Page 207: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/207.jpg)
MacroDefinitionDocumentation
#definePT_SEM_INIT ( s, c)
Initializeasemaphore
Thismacroinitializesasemaphorewithavalueforthecounter.Internally,thesemaphoresusean"unsignedint"torepresentthecounter,andthereforethe"count"argumentshouldbewithinrangeofanunsignedint.
Parameterss (structpt_sem*)Apointertothept_semstructrepresentingthesemaphore
c (unsignedint)Theinitialcountofthesemaphore.
#definePT_SEM_SIGNAL ( pt, s)
Signalasemaphore
Thismacrocarriesoutthe"signal"operationonthesemaphore.Thesignaloperationincrementsthecounterinsidethesemaphore,whicheventuallywillcausewaitingprotothreadstocontinueexecuting.
Parameterspt (structpt*)Apointertotheprotothread(structpt)inwhichtheoperationisexecuted.
s (structpt_sem*)Apointertothept_semstructrepresentingthesemaphore
![Page 208: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/208.jpg)
#definePT_SEM_WAIT ( pt, s)
Waitforasemaphore
Thismacrocarriesoutthe"wait"operationonthesemaphore.Thewaitoperationcausestheprotothreadtoblockwhilethecounteriszero.Whenthecounterreachesavaluelargerthanzero,theprotothreadwillcontinue.
Parameterspt (structpt*)Apointertotheprotothread(structpt)inwhichtheoperationisexecuted.
s (structpt_sem*)Apointertothept_semstructrepresentingthesemaphore
Generatedby 1.8.9.1
![Page 209: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/209.jpg)
RainbowBS RBSSource Base Protothreads
DataStructures|Macros
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
pt-sem.hFileReferencePt»Protothreadsemaphores
#include"pt.h"
Includedependencygraphforpt-sem.h:
Thisgraphshowswhichfilesdirectlyorindirectlyincludethisfile:
![Page 210: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/210.jpg)
DataStructuresstruct pt_sem
![Page 211: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/211.jpg)
Macros#define PT_SEM_INIT(s,c)#define PT_SEM_WAIT(pt,s)#define PT_SEM_SIGNAL(pt,s)
![Page 212: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/212.jpg)
DetailedDescription
Coutingsemaphoresimplementedonprotothreads
Generatedby 1.8.9.1
![Page 213: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/213.jpg)
DataFields
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
pt_semStructReferencePt»Protothreadsemaphores
Collaborationdiagramforpt_sem:
![Page 214: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/214.jpg)
DataFieldsunsignedint count
Thedocumentationforthisstructwasgeneratedfromthefollowingfile:
pt-sem.h
Generatedby 1.8.9.1
![Page 215: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/215.jpg)
RainbowBS RBSSource Base Protothreads
DataStructures|Macros
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
pt.hFileReferencePt
#include"lc.h"
Includedependencygraphforpt.h:
Thisgraphshowswhichfilesdirectlyorindirectlyincludethisfile:
![Page 216: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/216.jpg)
DataStructuresstruct pt
![Page 217: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/217.jpg)
Macros#define PT_WAITING0#define PT_YIELDED1#define PT_EXITED2#define PT_ENDED3
Initialization#define PT_INIT(pt)
Declarationanddefinition#define PT_THREAD(name_args)#define PT_BEGIN(pt)#define PT_END(pt)
Blockedwait#define PT_WAIT_UNTIL(pt,condition)#define PT_WAIT_WHILE(pt,cond)
Hierarchicalprotothreads#define PT_WAIT_THREAD(pt,thread)#define PT_SPAWN(pt,child,thread)
Exitingandrestarting#define PT_RESTART(pt)
![Page 218: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/218.jpg)
#define PT_EXIT(pt)
Callingaprotothread#define PT_SCHEDULE(f)
Yieldingfromaprotothread#define PT_YIELD(pt)#define PT_YIELD_UNTIL(pt,cond) Yieldfromtheprotothreaduntilaconditionoccurs.More...
![Page 219: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/219.jpg)
DetailedDescription
Protothreadsimplementation.
Generatedby 1.8.9.1
![Page 220: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/220.jpg)
DataFields
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
ptStructReferencePt
Collaborationdiagramforpt:
![Page 221: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/221.jpg)
DataFieldslc_t lc
Thedocumentationforthisstructwasgeneratedfromthefollowingfile:
pt.h
Generatedby 1.8.9.1
![Page 222: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/222.jpg)
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
DataStructures
Herearethedatastructureswithbriefdescriptions:
C etime_struct Eventtimerstructure C event_struct C MEM_struct C process_struct Processstructure(oneprocessconsistsone
protothread) C pt C pt_sem C tBLOCK C tDMMHEAD C tTime Timestructure
Generatedby 1.8.9.1
![Page 223: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/223.jpg)
DataFields
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
event_structStructReference
Collaborationdiagramforevent_struct:
![Page 224: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/224.jpg)
DataFieldsprocess_event_t evprocess_data_t data
tPROCESS* p
Thedocumentationforthisstructwasgeneratedfromthefollowingfile:
process.c
Generatedby 1.8.9.1
![Page 225: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/225.jpg)
DataFields
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
MEM_structStructReference
CollaborationdiagramforMEM_struct:
![Page 226: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/226.jpg)
DataFieldshDMM hDmm
U8* pData
USIZE size
structMEM_struct* pNextstructMEM_struct* pPrev
U8 lock_count
![Page 227: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/227.jpg)
FieldDocumentation
hDMMhDmm
DMMhandle
U8lock_count
0:notallocated,1:allocated,[2,255]:beingusedlock_count-1times.
U8*pData
pointerofmemoryarea
structMEM_struct*pNext
nexthandleinlinkedlist
structMEM_struct*pPrev
prevhandleinlinkedlist
USIZEsize
usablesizeofallocatedblock
Thedocumentationforthisstructwasgeneratedfromthefollowingfile:
![Page 229: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/229.jpg)
DataFields
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
tBLOCKStructReference
CollaborationdiagramfortBLOCK:
![Page 230: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/230.jpg)
DataFieldshDMM hDmm
U8* pData
U8 lock_count
![Page 231: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/231.jpg)
FieldDocumentation
hDMMhDmm
DMMhandle
U8lock_count
0:notallocated,1:allocated,[2,255]:beingusedlock_count-1times
U8*pData
pointerofdataarea
Thedocumentationforthisstructwasgeneratedfromthefollowingfile:
DMM.c
Generatedby 1.8.9.1
![Page 232: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/232.jpg)
DataFields
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
tDMMHEADStructReference
CollaborationdiagramfortDMMHEAD:
![Page 233: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/233.jpg)
DataFieldseDMTYPE eType
char* pName
void* pObjectArrayStart
void* pObjectArrayLast
void* pFreeObject
USIZE free_object_count
USIZE free_bytes
U8* pDataStart
U8* pDataEnd
USIZE block_sizeHMUTEX hMutex
![Page 234: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/234.jpg)
FieldDocumentation
USIZEblock_size
blocksizeifeTypeisDM_BLOCK
eDMTYPEeType
DMMtype
USIZEfree_bytes
countoffreebytesifeTypeisDM_POOLorDM_POOL_AUTO
USIZEfree_object_count
countoffreearray(tBLOCKortMEM)objects
HMUTEXhMutex
lock
U8*pDataEnd
pointerofdataend
U8*pDataStart
![Page 235: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/235.jpg)
pointerofdatahead
void*pFreeObject
pointerforacceleratingallocation
char*pName
DMMname
void*pObjectArrayLast
pointerofthelastarray(tBLOCKortMEM)object
void*pObjectArrayStart
pointerofthefirstarray(tBLOCKortMEM)object
Thedocumentationforthisstructwasgeneratedfromthefollowingfile:
DMM.c
Generatedby 1.8.9.1
![Page 236: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/236.jpg)
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
DataStructureIndex
E|M|P|T
M event_struct pt tDMMHEAD
p pt_sem tTimeMEM_struct te process_struct
tBLOCKetime_struct
E|M|P|T
Generatedby 1.8.9.1
![Page 237: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/237.jpg)
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
Hereisalistofalldocumentedstructandunionfieldswithlinkstothestruct/uniondocumentationforeachfield:
-b-
block_size:tDMMHEAD
-d-
day:tTimeday_of_week:tTime
-e-
eType:tDMMHEAD
-f-
free_bytes:tDMMHEADfree_object_count:tDMMHEAD
-h-
hDmm:MEM_struct,tBLOCKhMutex:tDMMHEADhour:tTime
-l-
lock_count:MEM_struct,tBLOCK
-m-
milliseconds:tTime
![Page 238: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/238.jpg)
minute:tTimemonth:tTime
-n-
name:process_structneedspoll:process_structnext:process_struct
-p-
pData:MEM_struct,tBLOCKpDataEnd:tDMMHEADpDataStart:tDMMHEADpFreeObject:tDMMHEADpName:tDMMHEADpNext:MEM_structpObjectArrayLast:tDMMHEADpObjectArrayStart:tDMMHEADpPrev:MEM_struct
-s-
second:tTimesize:MEM_structstate:process_struct
-y-
year:tTime
Generatedby 1.8.9.1
![Page 239: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/239.jpg)
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
-b-
block_size:tDMMHEAD
-d-
day:tTimeday_of_week:tTime
-e-
eType:tDMMHEAD
-f-
free_bytes:tDMMHEADfree_object_count:tDMMHEAD
-h-
hDmm:MEM_struct,tBLOCKhMutex:tDMMHEADhour:tTime
-l-
lock_count:MEM_struct,tBLOCK
-m-
milliseconds:tTimeminute:tTime
![Page 240: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/240.jpg)
month:tTime
-n-
name:process_structneedspoll:process_structnext:process_struct
-p-
pData:MEM_struct,tBLOCKpDataEnd:tDMMHEADpDataStart:tDMMHEADpFreeObject:tDMMHEADpName:tDMMHEADpNext:MEM_structpObjectArrayLast:tDMMHEADpObjectArrayStart:tDMMHEADpPrev:MEM_struct
-s-
second:tTimesize:MEM_structstate:process_struct
-y-
year:tTime
Generatedby 1.8.9.1
![Page 241: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/241.jpg)
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
FileList
Hereisalistofalldocumentedfileswithbriefdescriptions:
lc-addrlabels.h lc-switch.h lc.h Port.h pt-sem.h pt.h RainbowBS.h RainbowBSConf.h
Generatedby 1.8.9.1
![Page 242: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/242.jpg)
RainbowBS RBSSource Port
Functions
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
Port.hFileReference#include"RainbowBS.h"
IncludedependencygraphforPort.h:
![Page 243: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/243.jpg)
FunctionsBOOL Port_Init(void) Initializehardware.More...TICK Port_GetTickCount(void) Getsystemtick.More...
void Port_GetLocalTime(tTime*pTime) Getsystemlocaltime.More...
void Port_Delay(U32millisec) Delaysomemillisecond.More...
void Port_Printf_Error(constchar*s) Outputerrorinformation.More...
void Port_Printf_Warn(constchar*s) Outputwarninginformation.More...
void Port_Printf_Log(constchar*s) Outputloginformation.More...BOOL Port_GetMutex(HMUTEXhMutex) Waitforamutex.More...BOOL Port_FreeMutex(HMUTEXhMutex) Releaseamutex.More...
![Page 245: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/245.jpg)
FunctionDocumentation
voidPort_Delay ( U32 millisec )
Parameters[in]millisecmillisecondcount.
Hereisthecallergraphforthisfunction:
BOOLPort_FreeMutex ( HMUTEX hMutex )
Parameters[in] hMutex handleofmutex.
Hereisthecallergraphforthisfunction:
![Page 246: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/246.jpg)
voidPort_GetLocalTime ( tTime* pTime )
Parameters[out] pTime timestructure.
Hereisthecallergraphforthisfunction:
BOOLPort_GetMutex ( HMUTEX hMutex )
Parameters[in] hMutex handleofmutex.
![Page 247: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/247.jpg)
Hereisthecallergraphforthisfunction:
TICKPort_GetTickCount ( void )
Returnssystemtick.
Hereisthecallergraphforthisfunction:
BOOLPort_Init ( void )
![Page 248: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/248.jpg)
ReturnvaluesTRUE successful.FALSE failed.
Hereisthecallergraphforthisfunction:
voidPort_Printf_Error ( constchar* s )
Parameters[in] s string.
voidPort_Printf_Log ( constchar* s )
Parameters[in] s string.
voidPort_Printf_Warn ( constchar* s )
Parameters[in] s string.
Generatedby 1.8.9.1
![Page 249: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/249.jpg)
RainbowBS RBSSource
DataStructures|Macros|Typedefs|Functions
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
RainbowBS.hFileReference
#include<stddef.h>#include<windows.h>#include"RainbowBSConf.h"
#include"pt.h"
#include"pt-sem.h"
#include<stdio.h>
#include<string.h>
IncludedependencygraphforRainbowBS.h:
Thisgraphshowswhichfilesdirectlyorindirectlyincludethisfile:
![Page 250: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/250.jpg)
DataStructuresstruct tTime Timestructure.More...struct process_struct Processstructure(oneprocessconsistsoneprotothread).
More...struct etime_struct Eventtimerstructure.More...
![Page 251: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/251.jpg)
Macros#define RBS_VERSION"0.1.0"#define RBS_VERNUM0x0100#define RBS_VER_MAJOR0#define RBS_VER_MINOR1#define RBS_VER_REVISION0#define RBS_VER_SUBREVISION0#define FALSE0u#define TRUE1u#define USE_PARA(para)(para=(para))#define MIN(v0,v1)(((v0)>(v1))?(v1):(v0))#define MAX(v0,v1)(((v0)>(v1))?(v0):(v1))#define ABS(v)(((v)>=0)?(v):(-(v)))#define SWAP(a,b)(a=(a)+(b),b=(a)-(b),a=(a)-(b))#define COUNT_OF(a)(sizeof(a)/sizeof(a[0]))#define _STR(a)#a#define STR(a)_STR(a)#define _CONS(a,b)a##b
![Page 252: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/252.jpg)
#define CONS(a,b)_CONS(a,b)
#define ALIGN_F(pointer,power2)(((IPTRDIFF)(pointer)+((IPTRDIFF)((power2)-1)))&(~((IPTRDIFF)((power2)-1))))
#define ALIGN_B(pointer,power2)((IPTRDIFF)(pointer)&(~((IPTRDIFF)((power2)-1))))#define HDMM_NULLNULL#define HBLOCK_NULLNULL#define HMEM_NULLNULL#define PROCESS_NONENULL#define PROCESS_BROADCASTNULL
#define PROCESS_NAME_STRING(process)((NULL==(process))?"NoName":(process)->name)
predefinedeventtype#define PROCESS_EVENT_NONE0x80#define PROCESS_EVENT_INIT0x81#define PROCESS_EVENT_POLL0x82#define PROCESS_EVENT_EXIT0x83#define PROCESS_EVENT_SERVICE_REMOVED0x84#define PROCESS_EVENT_CONTINUE0x85#define PROCESS_EVENT_MSG0x86#define PROCESS_EVENT_EXITED0x87
![Page 253: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/253.jpg)
#define PROCESS_EVENT_TIMER0x88#define PROCESS_EVENT_COM0x89#define PROCESS_EVENT_MAX0x8a
processdeclarationanddefinition#define PROCESS_THREAD(name,ev,data) Definethebodyofaprocess.More...#define PROCESS_NAME(name)externtPROCESSname Declarethenameofaprocess.More...#define PROCESS(name,strname) Defineaprocess.More...
semaphoredeclarationanddefinition#define SEM_NAME(name)externstructpt_semsem_##name Declarethenameofasemaphore.More...#define SEM(name,count) Defineasemaphore.More...
processprotothreadfunctions#define PROCESS_BEGIN() Definethebeginningofaprocess.More...#define PROCESS_END() Definetheendofaprocess.More...#define PROCESS_WAIT_EVENT() Waitforaneventtobepostedtotheprocess.More...
![Page 254: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/254.jpg)
#define PROCESS_WAIT_EVENT_UNTIL(c) Waitforaneventtobepostedtotheprocess,withanextra
condition.More...#define PROCESS_YIELD() Yieldthecurrentlyrunningprocess.#define PROCESS_YIELD_UNTIL(c) Yieldthecurrentlyrunningprocessuntilaconditionoccurs.
More...#define PROCESS_WAIT_UNTIL(c) Waitforaconditiontooccur.More...#define PROCESS_WAIT_WHILE(c) Waitforaconditionnotoccur.More...#define PROCESS_EXIT() Exitthecurrentlyrunningprocess.#define PROCESS_PT_SPAWN(pt,thread) Spawnaprotothreadfromtheprocess.More...#define PROCESS_PAUSE() Yieldtheprocessforashortwhile.More...#define PROCESS_WAIT_SEM(name)#define PROCESS_SIGNAL_SEM(name)
pollandexithandlers
#define PROCESS_POLLHANDLER(handler)if(ev==PROCESS_EVENT_POLL){handler;} Specifyanactionwhenaprocessispolled.More...
#define PROCESS_EXITHANDLER(handler)if(ev==
![Page 255: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/255.jpg)
PROCESS_EVENT_EXIT){handler;} Specifyanactionwhenaprocessexits.More...
statementmacros
statementmacrosfordebug
#define RBS_DEBUG_STA(sta)sta Cstatementstaiscompiledifenabledebug.More...#define RBS_DEBUG_IF(exp,sta)if(exp){sta Cstatementifiscompiledifenabledebug.More...
#define RBS_DEBUG_ELSIF(sta1,exp,sta2)sta1;}elseif(exp){sta2 Cstatementelseifiscompiledifenabledebug.More...#define RBS_DEBUG_ENDIF(sta)sta;} Cstatement}forifiscompiledifenabledebug.More...
errormacrofunction
errormacrosfordebugoutput
#define RBS_DEBUG_ERROR(exp,s,sta) Outputerrorinformation.More...#define RBS_DEBUG_ERROR_FORMAT(exp,format,sta,...) Outputformaterrorinformationconditionally.More...
warningmacrofunction
warningmacrosfordebugoutput
#define RBS_DEBUG_WARN(exp,s)
![Page 256: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/256.jpg)
Outputwarninginformationconditionally.More...#define RBS_DEBUG_WARN_FORMAT(exp,format,...) Outputformatwarninginformationconditionally.More...
logmacrofunction
logmacrosfordebugoutput
#define RBS_DEBUG_LOG(s) Outputformatloginformation.More...#define RBS_DEBUG_LOG_FORMAT(format,...) Outputformatloginformation.More...
![Page 257: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/257.jpg)
Typedefstypedefuint8_t BOOL
typedefint8_t I8
typedefuint8_t U8
typedefint16_t I16
typedefuint16_t U16
typedefint32_t I32
typedefuint32_t U32
typedefint64_t I64
typedefuint64_t U64
typedefsize_t USIZE
typedefptrdiff_t IPTRDIFF
typedefU64 TICK
typedefvoid* hDMM
typedefvoid* hBLOCK
typedefvoid* hMEM
typedefU8 process_event_t
typedefvoid* process_data_t
![Page 258: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/258.jpg)
typedefstructprocess_struct tPROCESS Processstructure(oneprocessconsists
oneprotothread).More...
typedefstructetime_struct tETIME Eventtimerstructure.More...
![Page 259: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/259.jpg)
FunctionsBOOL RBS_Init(void)
InitializeRainbowBS.More...
U8 RBS_GetCPUBits(void) CPUword-width.More...
BOOL RBS_IsCPULittleEndian(void) CheckifCPUislittle-endian.More...
BOOL RBS_IsStackGrowDown(void) Checkifstackgrowsdown.More...
void RBS_MemSet8(U8*pDes,U8fill,USIZEnum) Setmemorybybyteunit.More...
void RBS_MemSet16(U16*pDes,U16fill,USIZEnum) Setmemorybytwo-bytesunit.More...
void RBS_MemSet32(U32*pDes,U32fill,USIZEnum) Setmemorybyfour-bytesunit.More...
void RBS_MemCpy8(U8*pDes,constU8*pSrc,USIZEnum) Copymemorybybyteunit.More...
U16 RBS_Read16L(constU8**ppData) Reada16-bitsentityinlittle-endian.More...
U32 RBS_Read32L(constU8**ppData) Reada32-bitsentityinlittle-endian.More...
void RBS_Write16L(U8**ppData,U16data) Writea16-bitsentityinlittle-endian.More...
![Page 260: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/260.jpg)
void RBS_Write32L(U8**ppData,U32data) Writea32-bitsentityinlittle-endian.More...
U16 RBS_Read16B(constU8**ppData) Reada16-bitsentityinbig-endian.More...
U32 RBS_Read32B(constU8**ppData) Reada32-bitsentityinbig-endian.More...
void RBS_Write16B(U8**ppData,U16data) Writea16-bitsentityinbig-endian.More...
void RBS_Write32B(U8**ppData,U32data) Writea32-bitsentityinbig-endian.More...
hDMM RBS_DMM_RegisterBlock(char*pName,void*pDM,USIZEsize,USIZEblock_size,HMUTEXhMutex)
Registerthememoryareaasadynamicblockmemoryarea.More...
hBLOCK RBS_DMM_AllocZeroBlock(hDMMhDmm)
Allocateafreeblockwithzeroinitializationfromthedynamicblockmemoryarea.More...
hBLOCK RBS_DMM_AllocBlock(hDMMhDmm)
Allocateafreeblockfromthedynamicblockmemoryarea.More...
BOOL RBS_DMM_FreeBlock(hBLOCKhBlock)
Freetheallocatedblock.More...
void* RBS_DMM_UseHBlock(hBLOCKhBlock) Gettheallocatedblockpointer.More...
BOOL RBS_DMM_UnuseHBlock(hBLOCKhBlock) Unusetheallocatedblockarea.More...
![Page 261: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/261.jpg)
hDMMRBS_DMM_RegisterPool(char*pName,void*pDM,USIZEsize,BOOLbAntiFrag,U16handle_count,HMUTEXhMutex)
Registerthememoryareaasadynamicpoolmemoryarea.More...
hMEM RBS_DMM_AllocZeroMem(hDMMhDmm,USIZEsize)
Allocateafreememorywithzeroinitializationfromthedynamicmemoryarea.More...
hMEM RBS_DMM_AllocMem(hDMMhDmm,USIZEsize)
Allocateafreememoryfromthedynamicmemoryarea.More...
hMEM RBS_DMM_ReallocMem(hMEMhMem,USIZEsize)
Reallocateafreememoryfromthesamedynamicmemoryarea.More...
BOOL RBS_DMM_FreeMem(hMEMhMem)
Freetheallocatedmemory.More...
void* RBS_DMM_UseHMem(hMEMhMem) Gettheallocatedmemorypointer.More...
BOOL RBS_DMM_UnuseHMem(hMEMhMem) Unusetheallocatedmemoryarea.More...
USIZE RBS_DMM_GetHMemSize(hMEMhMem) Gettheallocatedmemorysize.More...
systeminformationconstchar* RBS_GetVersionString(void) GetRainbowBSversionstring.More...constchar* RBS_GetSysInfo(void)
![Page 262: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/262.jpg)
Getsystemdescriptionstring.More...
processfunctionscalledfromdevicedrivers.BOOL process_poll(tPROCESS*ptProcess)
Requestaprocesstobepolled.More...
functionscalledbythesystemandboot-upcodeU16 process_run(void)
Runthesystemonce-callpollhandlersandprocessoneevent.More...
BOOL process_is_running(tPROCESS*ptProcess)
Checkifaprocessisrunning.More...
U16 process_nevents(void) Numberofeventswaitingtobeprocessed.More...
etimerfunctionscalledfromapplicationprogramsvoid etimer_set(tETIME*ptEtime,TICKinterval)
Setaneventtimer.More...
void etimer_reset(tETIME*ptEtime) Resetaneventtimerwiththesameintervalaswas
previouslyset.More...
void etimer_restart(tETIME*ptEtime) Restartaneventtimerfromthecurrentpointintime.
More...
void etimer_adjust(tETIME*ptEtime,inttimediff) Adjusttheexpirationtimeforaneventtimer.More...
TICK etimer_expiration_time(tETIME*ptEtime) Gettheexpirationtimefortheeventtimer.More...
![Page 263: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/263.jpg)
TICK etimer_start_time(tETIME*ptEtime) Getthestarttimefortheeventtimer.More...
BOOL etimer_expired(tETIME*ptEtime)
Checkifaneventtimerhasexpired.More...
void etimer_stop(tETIME*ptEtime) Stopapendingeventtimer.More...
etimerfunctionscalledfromtimerinterrupts,bythesystemvoid etimer_request_poll(void)
Maketheeventtimerawarethattheclockhaschanged.More...
BOOL etimer_pending(void)
Checkifthereareanynon-expiredeventtimers.More...
![Page 264: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/264.jpg)
timereleated#define RBS_TICK_MS(1000u/RBS_CFG_TICK_RATE)
TICK RBS_GetTickCount(void) Getsystemtick.More...
U64 RBS_GetRunTime(void) Getsystemrunningtime(ms).More...
void RBS_GetLocalTime(tTime*ptTime) Getsystemlocaltime.More...
void RBS_Delay(U32milliseconds) Delaysomemilliseconds.More...
![Page 265: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/265.jpg)
convertdigittostringenum ePOW{SHEX,SBINARY,SDECIMAL} Specifichex,binaryordecimal.More...
U8 RBS_Number2String(U32value,ePOWePow,U8length,char*pText)
ConvertunsigneddigittoASCIIstring.More...
![Page 266: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/266.jpg)
trigonometricreleted#define ANG_45DEG1024#define ANG_90DEG(2*ANG_45DEG)#define ANG_135DEG(3*ANG_45DEG)#define ANG_180DEG(4*ANG_45DEG)#define ANG_225DEG(5*ANG_45DEG)#define ANG_270DEG(6*ANG_45DEG)#define ANG_315DEG(7*ANG_45DEG)#define ANG_360DEG(8*ANG_45DEG)
int RBS_sin(intangle) Calculatesine.More...
int RBS_cos(intangle) Calculatecosine.More...
int RBS_tan(intangle) Calculatetangent.More...
int RBS_ctan(intangle) Calculatecotangent.More...
![Page 267: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/267.jpg)
processfunctionscalledfromapplicationprograms#define PROCESS_CURRENT()process_current
Getapointertothecurrentlyrunningprocess.More...
#definePROCESS_CONTEXT_BEGIN(ptProcess){tPROCESS*tmp_current=PROCESS_CURRENT();process_current=ptProcess
Switchcontexttoanotherprocess.More...
#define PROCESS_CONTEXT_END(ptProcess)process_current=tmp_current;} Endacontextswitch.More...
tPROCESS* process_current
BOOL process_start(tPROCESS*ptProcess,process_data_targ) Startaprocess.More...
BOOL process_post(tPROCESS*ptProcess,process_event_tev,void*data)
Postanasynchronouseventtooneorallprocesses.More...
void process_send(tPROCESS*ptProcess,process_event_tev,void*data) Sendasynchronouseventtoaprocess.More...
void process_exit(tPROCESS*ptProcess) Causeaprocesstoexit.More...process_event_t process_alloc_event(void) Allocateaglobaleventnumber.More...
![Page 268: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/268.jpg)
DetailedDescription
RainbowBSInterface.
Generatedby 1.8.9.1
![Page 269: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/269.jpg)
RainbowBS RBSSource Config
Macros
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
RainbowBSConf.hFileReference
Thisgraphshowswhichfilesdirectlyorindirectlyincludethisfile:
![Page 270: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/270.jpg)
Macros#define RBS_CFG_SYS_INFO"RainbowSys"#define RBS_CFG_TICK_RATE100#define RBS_CFG_CPU_WORD_SIZE32/*CPUwordsize*/#define RBS_CFG_CPU_BYTE_ORDER_L1/*CPUbyteorder*/
#define RBS_CFG_CPU_STACK_DOWN1/*stackgrowthdirection*/
#define RBS_APP_NONE0#define RBS_APP_PTP1#define RBS_APP_OS2#define RBS_CFG_APP_MODELRBS_APP_PTP#define RBS_CFG_PTP_NO_PROCESS_NAME0#define RBS_CFG_PTP_PROCESS_STATS0#define RBS_CFG_PTP_NUMEVENTS32#define RBS_CFG_DMM_ALIGN2
#define RBS_DEBUG_LEVEL_NOCHECK0/*Norunningtimechecksareperformed*/#define RBS_DEBUG_LEVEL_ERRORS1/*Errorsarerecorded*/
#define RBS_DEBUG_LEVEL_WARNINGS2/*ErrorsandWarningsarerecorded*/
![Page 271: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/271.jpg)
#define RBS_DEBUG_LEVEL_LOG3/*Errors,Warningsandlogsarerecorded*/
#define RBS_CFG_DEBUG_BUFSIZE300#define RBS_CFG_DEBUG_LEVELRBS_DEBUG_LEVEL_LOG
![Page 272: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/272.jpg)
DetailedDescription
RainbowBSConfiguration.
Generatedby 1.8.9.1
![Page 273: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/273.jpg)
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
Hereisalistofalldocumentedfunctions,variables,defines,enums,andtypedefswithlinkstothedocumentation:
-e-
ePOW:RainbowBS.hetimer_adjust():RainbowBS.hetimer_expiration_time():RainbowBS.hetimer_expired():RainbowBS.hetimer_pending():RainbowBS.hetimer_request_poll():RainbowBS.hetimer_reset():RainbowBS.hetimer_restart():RainbowBS.hetimer_set():RainbowBS.hetimer_start_time():RainbowBS.hetimer_stop():RainbowBS.h
-p-
Port_Delay():Port.hPort_FreeMutex():Port.hPort_GetLocalTime():Port.hPort_GetMutex():Port.hPort_GetTickCount():Port.hPort_Init():Port.hPort_Printf_Error():Port.hPort_Printf_Log():Port.hPort_Printf_Warn():Port.hPROCESS:RainbowBS.hprocess_alloc_event():RainbowBS.hPROCESS_BEGIN:RainbowBS.hPROCESS_CONTEXT_BEGIN:RainbowBS.hPROCESS_CONTEXT_END:RainbowBS.hPROCESS_CURRENT:RainbowBS.hPROCESS_END:RainbowBS.hprocess_exit():RainbowBS.h
![Page 274: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/274.jpg)
PROCESS_EXIT:RainbowBS.hPROCESS_EXITHANDLER:RainbowBS.hprocess_is_running():RainbowBS.hPROCESS_NAME:RainbowBS.hprocess_nevents():RainbowBS.hPROCESS_PAUSE:RainbowBS.hprocess_poll():RainbowBS.hPROCESS_POLLHANDLER:RainbowBS.hprocess_post():RainbowBS.hPROCESS_PT_SPAWN:RainbowBS.hprocess_run():RainbowBS.hprocess_send():RainbowBS.hPROCESS_SIGNAL_SEM:RainbowBS.hprocess_start():RainbowBS.hPROCESS_THREAD:RainbowBS.hPROCESS_WAIT_EVENT:RainbowBS.hPROCESS_WAIT_EVENT_UNTIL:RainbowBS.hPROCESS_WAIT_SEM:RainbowBS.hPROCESS_WAIT_UNTIL:RainbowBS.hPROCESS_WAIT_WHILE:RainbowBS.hPROCESS_YIELD:RainbowBS.hPROCESS_YIELD_UNTIL:RainbowBS.hPT_BEGIN:pt.hPT_END:pt.hPT_EXIT:pt.hPT_INIT:pt.hPT_RESTART:pt.hPT_SCHEDULE:pt.hPT_SEM_INIT:pt-sem.hPT_SEM_SIGNAL:pt-sem.hPT_SEM_WAIT:pt-sem.hPT_SPAWN:pt.hPT_THREAD:pt.hPT_WAIT_THREAD:pt.hPT_WAIT_UNTIL:pt.hPT_WAIT_WHILE:pt.hPT_YIELD:pt.hPT_YIELD_UNTIL:pt.h
-r-
![Page 275: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/275.jpg)
RBS_cos():RainbowBS.hRBS_ctan():RainbowBS.hRBS_DEBUG_ELSIF:RainbowBS.hRBS_DEBUG_ENDIF:RainbowBS.hRBS_DEBUG_ERROR:RainbowBS.hRBS_DEBUG_ERROR_FORMAT:RainbowBS.hRBS_DEBUG_IF:RainbowBS.hRBS_DEBUG_LOG:RainbowBS.hRBS_DEBUG_LOG_FORMAT:RainbowBS.hRBS_DEBUG_STA:RainbowBS.hRBS_DEBUG_WARN:RainbowBS.hRBS_DEBUG_WARN_FORMAT:RainbowBS.hRBS_Delay():RainbowBS.hRBS_DMM_AllocBlock():RainbowBS.hRBS_DMM_AllocMem():RainbowBS.hRBS_DMM_AllocZeroBlock():RainbowBS.hRBS_DMM_AllocZeroMem():RainbowBS.hRBS_DMM_FreeBlock():RainbowBS.hRBS_DMM_FreeMem():RainbowBS.hRBS_DMM_GetHMemSize():RainbowBS.hRBS_DMM_ReallocMem():RainbowBS.hRBS_DMM_RegisterBlock():RainbowBS.hRBS_DMM_RegisterPool():RainbowBS.hRBS_DMM_UnuseHBlock():RainbowBS.hRBS_DMM_UnuseHMem():RainbowBS.hRBS_DMM_UseHBlock():RainbowBS.hRBS_DMM_UseHMem():RainbowBS.hRBS_GetCPUBits():RainbowBS.hRBS_GetLocalTime():RainbowBS.hRBS_GetRunTime():RainbowBS.hRBS_GetSysInfo():RainbowBS.hRBS_GetTickCount():RainbowBS.hRBS_GetVersionString():RainbowBS.hRBS_Init():RainbowBS.hRBS_IsCPULittleEndian():RainbowBS.hRBS_IsStackGrowDown():RainbowBS.hRBS_MemCpy8():RainbowBS.hRBS_MemSet16():RainbowBS.hRBS_MemSet32():RainbowBS.hRBS_MemSet8():RainbowBS.h
![Page 276: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/276.jpg)
RBS_Number2String():RainbowBS.hRBS_Read16B():RainbowBS.hRBS_Read16L():RainbowBS.hRBS_Read32B():RainbowBS.hRBS_Read32L():RainbowBS.hRBS_sin():RainbowBS.hRBS_tan():RainbowBS.hRBS_Write16B():RainbowBS.hRBS_Write16L():RainbowBS.hRBS_Write32B():RainbowBS.hRBS_Write32L():RainbowBS.h
-s-
SBINARY:RainbowBS.hSDECIMAL:RainbowBS.hSEM:RainbowBS.hSEM_NAME:RainbowBS.hSHEX:RainbowBS.h
-t-
tETIME:RainbowBS.htPROCESS:RainbowBS.h
Generatedby 1.8.9.1
![Page 277: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/277.jpg)
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
-e-
etimer_adjust():RainbowBS.hetimer_expiration_time():RainbowBS.hetimer_expired():RainbowBS.hetimer_pending():RainbowBS.hetimer_request_poll():RainbowBS.hetimer_reset():RainbowBS.hetimer_restart():RainbowBS.hetimer_set():RainbowBS.hetimer_start_time():RainbowBS.hetimer_stop():RainbowBS.h
-p-
Port_Delay():Port.hPort_FreeMutex():Port.hPort_GetLocalTime():Port.hPort_GetMutex():Port.hPort_GetTickCount():Port.hPort_Init():Port.hPort_Printf_Error():Port.hPort_Printf_Log():Port.hPort_Printf_Warn():Port.hprocess_alloc_event():RainbowBS.hprocess_exit():RainbowBS.hprocess_is_running():RainbowBS.hprocess_nevents():RainbowBS.hprocess_poll():RainbowBS.hprocess_post():RainbowBS.hprocess_run():RainbowBS.hprocess_send():RainbowBS.hprocess_start():RainbowBS.h
![Page 278: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/278.jpg)
-r-
RBS_cos():RainbowBS.hRBS_ctan():RainbowBS.hRBS_Delay():RainbowBS.hRBS_DMM_AllocBlock():RainbowBS.hRBS_DMM_AllocMem():RainbowBS.hRBS_DMM_AllocZeroBlock():RainbowBS.hRBS_DMM_AllocZeroMem():RainbowBS.hRBS_DMM_FreeBlock():RainbowBS.hRBS_DMM_FreeMem():RainbowBS.hRBS_DMM_GetHMemSize():RainbowBS.hRBS_DMM_ReallocMem():RainbowBS.hRBS_DMM_RegisterBlock():RainbowBS.hRBS_DMM_RegisterPool():RainbowBS.hRBS_DMM_UnuseHBlock():RainbowBS.hRBS_DMM_UnuseHMem():RainbowBS.hRBS_DMM_UseHBlock():RainbowBS.hRBS_DMM_UseHMem():RainbowBS.hRBS_GetCPUBits():RainbowBS.hRBS_GetLocalTime():RainbowBS.hRBS_GetRunTime():RainbowBS.hRBS_GetSysInfo():RainbowBS.hRBS_GetTickCount():RainbowBS.hRBS_GetVersionString():RainbowBS.hRBS_Init():RainbowBS.hRBS_IsCPULittleEndian():RainbowBS.hRBS_IsStackGrowDown():RainbowBS.hRBS_MemCpy8():RainbowBS.hRBS_MemSet16():RainbowBS.hRBS_MemSet32():RainbowBS.hRBS_MemSet8():RainbowBS.hRBS_Number2String():RainbowBS.hRBS_Read16B():RainbowBS.hRBS_Read16L():RainbowBS.hRBS_Read32B():RainbowBS.hRBS_Read32L():RainbowBS.hRBS_sin():RainbowBS.hRBS_tan():RainbowBS.hRBS_Write16B():RainbowBS.h
![Page 279: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/279.jpg)
RBS_Write16L():RainbowBS.hRBS_Write32B():RainbowBS.hRBS_Write32L():RainbowBS.h
Generatedby 1.8.9.1
![Page 280: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/280.jpg)
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
tETIME:RainbowBS.htPROCESS:RainbowBS.h
Generatedby 1.8.9.1
![Page 282: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/282.jpg)
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
SBINARY:RainbowBS.hSDECIMAL:RainbowBS.hSHEX:RainbowBS.h
Generatedby 1.8.9.1
![Page 283: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/283.jpg)
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
-p-
PROCESS:RainbowBS.hPROCESS_BEGIN:RainbowBS.hPROCESS_CONTEXT_BEGIN:RainbowBS.hPROCESS_CONTEXT_END:RainbowBS.hPROCESS_CURRENT:RainbowBS.hPROCESS_END:RainbowBS.hPROCESS_EXIT:RainbowBS.hPROCESS_EXITHANDLER:RainbowBS.hPROCESS_NAME:RainbowBS.hPROCESS_PAUSE:RainbowBS.hPROCESS_POLLHANDLER:RainbowBS.hPROCESS_PT_SPAWN:RainbowBS.hPROCESS_SIGNAL_SEM:RainbowBS.hPROCESS_THREAD:RainbowBS.hPROCESS_WAIT_EVENT:RainbowBS.hPROCESS_WAIT_EVENT_UNTIL:RainbowBS.hPROCESS_WAIT_SEM:RainbowBS.hPROCESS_WAIT_UNTIL:RainbowBS.hPROCESS_WAIT_WHILE:RainbowBS.hPROCESS_YIELD:RainbowBS.hPROCESS_YIELD_UNTIL:RainbowBS.hPT_BEGIN:pt.hPT_END:pt.hPT_EXIT:pt.hPT_INIT:pt.hPT_RESTART:pt.hPT_SCHEDULE:pt.hPT_SEM_INIT:pt-sem.hPT_SEM_SIGNAL:pt-sem.hPT_SEM_WAIT:pt-sem.hPT_SPAWN:pt.hPT_THREAD:pt.h
![Page 284: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/284.jpg)
PT_WAIT_THREAD:pt.hPT_WAIT_UNTIL:pt.hPT_WAIT_WHILE:pt.hPT_YIELD:pt.hPT_YIELD_UNTIL:pt.h
-r-
RBS_DEBUG_ELSIF:RainbowBS.hRBS_DEBUG_ENDIF:RainbowBS.hRBS_DEBUG_ERROR:RainbowBS.hRBS_DEBUG_ERROR_FORMAT:RainbowBS.hRBS_DEBUG_IF:RainbowBS.hRBS_DEBUG_LOG:RainbowBS.hRBS_DEBUG_LOG_FORMAT:RainbowBS.hRBS_DEBUG_STA:RainbowBS.hRBS_DEBUG_WARN:RainbowBS.hRBS_DEBUG_WARN_FORMAT:RainbowBS.h
-s-
SEM:RainbowBS.hSEM_NAME:RainbowBS.h
Generatedby 1.8.9.1
![Page 285: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/285.jpg)
RainbowBS
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
RainbowBSDirectoryReference
DirectorydependencygraphforRainbowBS:
![Page 287: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/287.jpg)
RainbowBS RBSSource
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
RBSSourceDirectoryReference
DirectorydependencygraphforRBSSource:
![Page 288: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/288.jpg)
Directoriesdirectory Basedirectory Configdirectory Port
![Page 290: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/290.jpg)
RainbowBS RBSSource Base
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
BaseDirectoryReference
DirectorydependencygraphforBase:
![Page 291: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/291.jpg)
Directoriesdirectory Processdirectory Protothreads
![Page 292: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/292.jpg)
Filesfile Convert.cfile Debug.cfile DMM.cfile MemOP.cfile System.c
Generatedby 1.8.9.1
![Page 293: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/293.jpg)
RainbowBS RBSSource Base Protothreads
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
ProtothreadsDirectoryReference
DirectorydependencygraphforProtothreads:
![Page 294: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/294.jpg)
Filesfile lc-addrlabels.hfile lc-switch.hfile lc.hfile pt-sem.hfile pt.h
Generatedby 1.8.9.1
![Page 295: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/295.jpg)
RainbowBS RBSSource Port
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
PortDirectoryReference
DirectorydependencygraphforPort:
![Page 297: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/297.jpg)
RainbowBS RBSSource Config
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
ConfigDirectoryReference
DirectorydependencygraphforConfig:
![Page 299: RainbowBS Manual · RainbowBS(RBS) is an open-source base library developed for embedded systems especially with limit resources. RBS is written by C language in compliance with the](https://reader030.vdocuments.us/reader030/viewer/2022040522/5e7eb714ae59301758138295/html5/thumbnails/299.jpg)
RainbowBS RBSSource Base Process
RainbowBSManualv0.1.0WrittenbyQWQ([email protected])
ProcessDirectoryReference
DirectorydependencygraphforProcess: