00001
00039 #ifndef REGS_XMEGA_PORTCFG_H_INCLUDED
00040 #define REGS_XMEGA_PORTCFG_H_INCLUDED
00041
00042 #include <chip/memory-map.h>
00043 #include <io.h>
00044
00051
00052
00053 #define PORTCFG_MPCMASK 0x0 //!< Multi-Pin Configuration Mask Register
00054 #define PORTCFG_VPCTRLA 0x2 //!< Virtual Port-Map Control A Register
00055 #define PORTCFG_VPCTRLB 0x3 //!< Virtual Port-Map Control B Register
00056 #define PORTCFG_CLKEVOUT 0x4 //!< Clock and Event Out Register
00057
00058
00060
00061 #define PORTCFG_VPCTRLA_VP0MAP_START 0 //!< Virtual Port 0 Mapping
00062 #define PORTCFG_VPCTRLA_VP0MAP_SIZE 4 //!< Virtual Port 0 Mapping
00063 #define PORTCFG_VPCTRLA_VP1MAP_START 4 //!< Virtual Port 1 Mapping
00064 #define PORTCFG_VPCTRLA_VP1MAP_SIZE 4 //!< Virtual Port 1 Mapping
00065
00066
00068
00069 #define PORTCFG_VPCTRLB_VP2MAP_START 0 //!< Virtual Port 2 Mapping
00070 #define PORTCFG_VPCTRLB_VP2MAP_SIZE 4 //!< Virtual Port 2 Mapping
00071 #define PORTCFG_VPCTRLB_VP3MAP_START 4 //!< Virtual Port 3 Mapping
00072 #define PORTCFG_VPCTRLB_VP3MAP_SIZE 4 //!< Virtual Port 3 Mapping
00073
00074
00076
00077 #define PORTCFG_CLKEVOUT_CLKOUT_START 0 //!< Clock Output Port
00078 #define PORTCFG_CLKEVOUT_CLKOUT_SIZE 2 //!< Clock Output Port
00079 #define PORTCFG_CLKEVOUT_EVOUT_START 4 //!< Event Output Port
00080 #define PORTCFG_CLKEVOUT_EVOUT_SIZE 2 //!< Event Output Port
00081
00082
00084
00085 #define PORTCFG_PORTA 0x0 //!< Map Port A to Virtual Port
00086 #define PORTCFG_PORTB 0x1 //!< Map Port B to Virtual Port
00087 #define PORTCFG_PORTC 0x2 //!< Map Port C to Virtual Port
00088 #define PORTCFG_PORTD 0x3 //!< Map Port D to Virtual Port
00089 #define PORTCFG_PORTE 0x4 //!< Map Port E to Virtual Port
00090 #define PORTCFG_PORTF 0x5 //!< Map Port F to Virtual Port
00091 #define PORTCFG_PORTG 0x6 //!< Map Port G to Virtual Port
00092 #define PORTCFG_PORTH 0x7 //!< Map Port H to Virtual Port
00093 #define PORTCFG_PORTJ 0x8 //!< Map Port J to Virtual Port
00094 #define PORTCFG_PORTK 0x9 //!< Map Port K to Virtual Port
00095 #define PORTCFG_PORTL 0xa //!< Map Port L to Virtual Port
00096 #define PORTCFG_PORTM 0xb //!< Map Port M to Virtual Port
00097 #define PORTCFG_PORTN 0xc //!< Map Port N to Virtual Port
00098 #define PORTCFG_PORTP 0xd //!< Map Port P to Virtual Port
00099 #define PORTCFG_PORTQ 0xe //!< Map Port Q to Virtual Port
00100 #define PORTCFG_PORTR 0xf //!< Map Port R to Virtual Port
00101
00102
00104
00105 #define PORTCFG_CLKOUT_OFF 0x0 //!< Clock Out Disabled
00106 #define PORTCFG_CLKOUT_PC7 0x1 //!< Clock Output on Port C Pin 7
00107 #define PORTCFG_CLKOUT_PD7 0x2 //!< Clock Output on Port D Pin 7
00108 #define PORTCFG_CLKOUT_PE7 0x3 //!< Clock Output on Port E Pin 7
00109
00110
00112
00113 #define PORTCFG_EVOUT_OFF 0x0 //!< Event Out Disabled
00114 #define PORTCFG_EVOUT_PC7 0x1 //!< Event Channel 0 on Port C Pin 7
00115 #define PORTCFG_EVOUT_PD7 0x2 //!< Event Channel 0 on Port D Pin 7
00116 #define PORTCFG_EVOUT_PE7 0x3 //!< Event Channel 0 on Port E Pin 7
00117
00118
00120
00121
00122 #define PORTCFG_BIT(name) \
00123 (1U << PORTCFG_##name##_BIT)
00124
00125 #define PORTCFG_BF(name, value) \
00126 ((value) << PORTCFG_##name##_START)
00127
00128 #define PORTCFG_BFMASK(name) \
00129 (((1U << %s_##name##_SIZE) - 1) << %s_##name##_START)
00130
00131 #define PORTCFG_BFEXT(name, regval) \
00132 (((regval) >> PORTCFG_##name##_START) \
00133 & ((1U << PORTCFG_##name##_SIZE) - 1))
00134
00135 #define PORTCFG_BFINS(name, value, regval) \
00136 (((regval) & ~(((1U << PORTCFG_##name##_SIZE) - 1) \
00137 << PORTCFG_##name##_START)) \
00138 | PORTCFG_BF(name, value))
00139
00140
00142
00143
00144 #define portcfg_read_reg(base, reg) \
00145 mmio_read8((void *)((uintptr_t)(base) + PORTCFG_##reg))
00146
00147 #define portcfg_write_reg(base, reg, value) \
00148 mmio_write8((void *)((uintptr_t)(base) + PORTCFG_##reg), (value))
00149
00150
00152 #endif