00001
00067 #include "port_driver.h"
00068
00069
00070
00080 void PORT_ConfigureInterrupt0( PORT_t * port,
00081 PORT_INT0LVL_t intLevel,
00082 uint8_t pinMask )
00083 {
00084 port->INTCTRL = ( port->INTCTRL & ~PORT_INT0LVL_gm ) | intLevel;
00085 port->INT0MASK = pinMask;
00086 }
00087
00088
00098 void PORT_ConfigureInterrupt1( PORT_t * port,
00099 PORT_INT1LVL_t intLevel,
00100 uint8_t pinMask )
00101 {
00102 port->INTCTRL = ( port->INTCTRL & ~PORT_INT1LVL_gm ) | intLevel;
00103 port->INT1MASK = pinMask;
00104 }
00105
00106
00107
00117 void PORT_ConfigurePins( PORT_t * port,
00118 uint8_t pinMask,
00119 uint8_t slewRateEnable,
00120 uint8_t invertEnable,
00121 PORT_OPC_t opc,
00122 PORT_ISC_t isc)
00123 {
00124
00125 uint8_t temp = (uint8_t) opc |
00126 isc |
00127 (slewRateEnable ? PORT_SRLEN_bm : 0) |
00128 (invertEnable ? PORT_INVEN_bm : 0);
00129
00130
00131
00132
00133 uint8_t sreg = SREG;
00134
00135 cli();
00136 PORTCFG.MPCMASK = pinMask;
00137 port->PIN0CTRL = temp;
00138
00139
00140 SREG = sreg;
00141 }
00142
00143
00151 void PORT_MapVirtualPort0(PORTCFG_VP0MAP_t realPort)
00152 {
00153 PORTCFG.VPCTRLA = ( PORTCFG.VPCTRLA & ~PORTCFG_VP0MAP_gm ) | realPort;
00154 }
00155
00156
00164 void PORT_MapVirtualPort1(PORTCFG_VP1MAP_t realPort)
00165 {
00166 PORTCFG.VPCTRLA = ( PORTCFG.VPCTRLA & ~PORTCFG_VP1MAP_gm ) | realPort;
00167 }
00168
00169
00177 void PORT_MapVirtualPort2(PORTCFG_VP2MAP_t realPort)
00178 {
00179 PORTCFG.VPCTRLB = ( PORTCFG.VPCTRLB & ~PORTCFG_VP2MAP_gm ) | realPort;
00180 }
00181
00182
00190 void PORT_MapVirtualPort3(PORTCFG_VP3MAP_t realPort)
00191 {
00192 PORTCFG.VPCTRLB = ( PORTCFG.VPCTRLB & ~PORTCFG_VP3MAP_gm ) | realPort;
00193 }