intrinsics.h1/****************************************************IntrinsicfunctionsfortheIAREmbeddedWorkbenchforMSP430.**Copyright?2002-2008IARSystemsAB.**$Revision:5178$***************************************************/#ifndef__INTRINSICS_H#define__INTRINSICS_H#ifndef_SYSTEM_BUILD#pragmasystem_include#endif#pragmalanguage=save#pragmalanguage=extended/**Thereturnvalueof__get_interrupt_state.*/typedefunsignedshortistate_t;#ifdef__cplusplusexternC{#endif__intrinsicvoid__no_operation(void);__intrinsicvoid__enable_interrupt(void);__intrinsicvoid__disable_interrupt(void);__intrinsicistate_t__get_interrupt_state(void);__intrinsicvoid__set_interrupt_state(istate_t);__intrinsicvoid__op_code(unsignedshort);__intrinsicunsignedshort__swap_bytes(unsignedshort);__intrinsicvoid__bic_SR_register(unsignedshort);intrinsics.h2__intrinsicvoid__bis_SR_register(unsignedshort);__intrinsicunsignedshort__get_SR_register(void);__intrinsicvoid__bic_SR_register_on_exit(unsignedshort);__intrinsicvoid__bis_SR_register_on_exit(unsignedshort);__intrinsicunsignedshort__get_SR_register_on_exit(void);__intrinsicunsignedshort__bcd_add_short(unsignedshort,unsignedshort);__intrinsicunsignedlong__bcd_add_long(unsignedlong,unsignedlong);__intrinsicunsignedlonglong__bcd_add_long_long(unsignedlonglong,unsignedlonglong);/**Supportforefficientswitch:es.E.g.switch(__even_in_range(x,10))**Notethatthevaluemustbeevenandintherangefrom0to*__bound,inclusive.Nocodewillbegeneratedthatchecksthis.**Thisistypicallyusedinsideinterruptdispatchfunctions,to*switchonspecialprocessorregisterslikeTAIV.*/__intrinsicunsignedshort__even_in_range(unsignedshort__value,unsignedshort__bound);/*Insertadelaywithaspecificnumberofcycles.*/__intrinsicvoid__delay_cycles(unsignedlong__cycles);/**ThefollowingR4/R5intrinsicfunctionsareonlyavailablewhen*thecorrespondingregisterislocked.*/__intrinsicunsignedshort__get_R4_register(void);__intrinsicvoid__set_R4_register(unsignedshort);__intrinsicunsignedshort__get_R5_register(void);__intrinsicvoid__set_R5_register(unsignedshort);__intrinsicunsignedshort__get_SP_register(void);intrinsics.h3__intrinsicvoid__set_SP_register(unsignedshort);/**Iftheapplicationprovidesthisfunction,itiscalledbythe*startupcodebeforevariablesareinitialized.Ifthefunction*returns0thedatasegmentswillnotbeinitialized.*/__intrinsicint__low_level_init(void);/*----------------------------------------*MSP430X-specificintrinsicfunctions.*//**Intrinsicfunctionstoallowaccesstothefull1Mbytememory*rangeinsmalldatamodel.**Thefunctionsareavailableinmediumandlargedatamodel*aswell,howeveritisrecommendedtoaccessmemoryusingnormal*__data20variablesand/orpointers.**Pleasenotethatinterruptsmustbedisabledwhenthefollowing*intrinsicsareused.*/__intrinsicvoid__data20_write_char(unsignedlong__addr,unsignedchar__value);__intrinsicvoid__data20_write_short(unsignedlong__addr,unsignedshort__value);__intrinsicvoid__data20_write_long(unsignedlong__addr,unsignedlong__value);__intrinsicunsignedchar__data20_read_char(unsignedlong__addr);__intrinsicunsignedshort__data20_read_short(unsignedlong__addr);__intrinsicunsignedlong__data20_read_long(unsignedlong__addr);/**Thefollowingtwofunctionscanbeusedtoaccess20-bitSFRsinthe*lower64kB.Theyareonlyavailableinextendedmode(--core=430X).*/intrinsics.h4__intrinsicvoid__data16_write_addr(unsignedshort__addr,unsignedlong__value);__intrinsicunsignedlong__data16_read_addr(unsignedshort__addr);#ifdef__cplusplus}#endif/**Aliasforlocationsusedforglobalregistervariables.Forexample,*__no_init__regvarintx@__R4;.*/#define__R44#define__R55/**Controlbitsintheprocessorstatusregister,SR.*/#define__SR_GIE(13)#define__SR_CPU_OFF(14)#define__SR_OSC_OFF(15)#define__SR_SCG0(16)#define__SR_SCG1(17)/**Functionsforcontrollingtheprocessoroperationmodes.*/#define__low_power_mode_0()(__bis_SR_register(__SR_GIE\|__SR_CPU_OFF))#define__low_power_mode_1()(__bis_SR_register(__SR_GIE\|__SR_CPU_OFF\|__SR_SCG0))#define__low_power_mode_2()(__bis_SR_register(__SR_GIE\|__SR_CPU_OFF\|__SR_SCG1))intrinsics.h5#define__low_power_mode_3()\(__bis_SR_register(__SR_GIE\|__SR_CPU_OFF\|__SR_SCG0\|__SR_SCG1))#define__low_power_mode_4()\(__bis_SR_register(__SR_GIE\|__SR_CPU_OFF\|__SR_SCG0\|__SR_SCG1\|__SR_OSC_OFF))#define__low_power_mode_off_on_exit()\(__bic_SR_register_on_exit(__SR_CPU_OFF\|__SR_SCG0\|__SR_SCG1\|__SR_OSC_OFF))#pragmalanguage=restore#endif/*__INTRINSICS_H*/