Hey guys! First version of EB-series io headers are available for download in an ATPACK! #461
Replies: 3 comments 2 replies
-
And the big Kahunas! TCE /*
--------------------------------------------------------------------------
TCE - 16-bit Timer/Counter Type E
--------------------------------------------------------------------------
*/
/* 16-bit Timer/Counter Type E */
typedef struct TCE_struct
{
register8_t CTRLA; /* Control A */
register8_t CTRLB; /* Control B */
register8_t CTRLC; /* Control C */
register8_t CTRLD; /* Control D */
register8_t CTRLECLR; /* Control E Clear */
register8_t CTRLESET; /* Control E Set */
register8_t CTRLFCLR; /* Control F Clear */
register8_t CTRLFSET; /* Control F Set */
register8_t EVGENCTRL; /* Event Generation Control */
register8_t EVCTRL; /* Event Control */
register8_t INTCTRL; /* Interrupt Control */
register8_t INTFLAGS; /* Interrupt Flags */
register8_t reserved_1[2];
register8_t DBGCTRL; /* Debug Control */
register8_t TEMP; /* Temporary data for 16-bit Access */
register8_t reserved_2[16];
_WORDREGISTER(CNT); /* Count */
_WORDREGISTER(AMP); /* Amplitude */
_WORDREGISTER(OFFSET); /* Offset */
_WORDREGISTER(PER); /* Period */
_WORDREGISTER(CMP0); /* Compare 0 */
_WORDREGISTER(CMP1); /* Compare 1 */
_WORDREGISTER(CMP2); /* Compare 2 */
_WORDREGISTER(CMP3); /* Compare 3 */
register8_t reserved_3[6];
_WORDREGISTER(PERBUF); /* Period Buffer */
_WORDREGISTER(CMP0BUF); /* Compare 0 Buffer */
_WORDREGISTER(CMP1BUF); /* Compare 1 Buffer */
_WORDREGISTER(CMP2BUF); /* Compare 2 Buffer */
_WORDREGISTER(CMP3BUF); /* Compare 3 Buffer */
} TCE_t;
/* Clock Selection */
typedef enum TCE_CLKSEL_enum
{
TCE_CLKSEL_DIV1_gc = (0x00<<1), /* System Clock */
TCE_CLKSEL_DIV2_gc = (0x01<<1), /* System Clock / 2 */
TCE_CLKSEL_DIV4_gc = (0x02<<1), /* System Clock / 4 */
TCE_CLKSEL_DIV8_gc = (0x03<<1), /* System Clock / 8 */
TCE_CLKSEL_DIV16_gc = (0x04<<1), /* System Clock / 16 */
TCE_CLKSEL_DIV64_gc = (0x05<<1), /* System Clock / 64 */
TCE_CLKSEL_DIV256_gc = (0x06<<1), /* System Clock / 256 */
TCE_CLKSEL_DIV1024_gc = (0x07<<1) /* System Clock / 1024 */
} TCE_CLKSEL_t;
/* Command select */
typedef enum TCE_CMD_enum
{
TCE_CMD_NONE_gc = (0x00<<2), /* No Command */
TCE_CMD_UPDATE_gc = (0x01<<2), /* Force Update */
TCE_CMD_RESTART_gc = (0x02<<2), /* Force Restart */
TCE_CMD_RESET_gc = (0x03<<2) /* Force Hard Reset */
} TCE_CMD_t;
/* Compare # Event select */
typedef enum TCE_CMP0EV_enum
{
TCE_CMP0EV_PULSE_gc = (0x00<<4), /* Event output for CMP is a pulse */
TCE_CMP0EV_WAVEFORM_gc = (0x01<<4) /* Event output for CMP is equal to waveform */
} TCE_CMP0EV_t;
/* Compare # Event select */
typedef enum TCE_CMP1EV_enum
{
TCE_CMP1EV_PULSE_gc = (0x00<<5), /* Event output for CMP is a pulse */
TCE_CMP1EV_WAVEFORM_gc = (0x01<<5) /* Event output for CMP is equal to waveform */
} TCE_CMP1EV_t;
/* Compare # Event select */
typedef enum TCE_CMP2EV_enum
{
TCE_CMP2EV_PULSE_gc = (0x00<<6), /* Event output for CMP is a pulse */
TCE_CMP2EV_WAVEFORM_gc = (0x01<<6) /* Event output for CMP is equal to waveform */
} TCE_CMP2EV_t;
/* Compare # Event select */
typedef enum TCE_CMP3EV_enum
{
TCE_CMP3EV_PULSE_gc = (0x00<<7), /* Event output for CMP is a pulse */
TCE_CMP3EV_WAVEFORM_gc = (0x01<<7) /* Event output for CMP is equal to waveform */
} TCE_CMP3EV_t;
/* Direction select */
typedef enum TCE_DIR_enum
{
TCE_DIR_UP_gc = (0x00<<0), /* Count up */
TCE_DIR_DOWN_gc = (0x01<<0) /* Count down */
} TCE_DIR_t;
/* Event Action A select */
typedef enum TCE_EVACTA_enum
{
TCE_EVACTA_CNT_POSEDGE_gc = (0x00<<1), /* Count on positive edge event */
TCE_EVACTA_CNT_ANYEDGE_gc = (0x01<<1), /* Count on any edge event */
TCE_EVACTA_CNT_HIGHLVL_gc = (0x02<<1), /* Count on prescaled clock while event line is 1. */
TCE_EVACTA_UPDOWN_gc = (0x03<<1) /* Count on prescaled clock. Event controls count direction. Up-count when event line is 0, down-count when event line is 1. */
} TCE_EVACTA_t;
/* Event Action B select */
typedef enum TCE_EVACTB_enum
{
TCE_EVACTB_NONE_gc = (0x00<<5), /* No Action */
TCE_EVACTB_UPDOWN_gc = (0x03<<5), /* Count on prescaled clock. Event controls count direction. Up-count when event line is 0, down-count when event line is 1. */
TCE_EVACTB_RESTART_POSEDGE_gc = (0x04<<5), /* Restart counter at positive edge event */
TCE_EVACTB_RESTART_ANYEDGE_gc = (0x05<<5), /* Restart counter on any edge event */
TCE_EVACTB_RESTART_HIGHLVL_gc = (0x06<<5) /* Restart counter while event line is 1. */
} TCE_EVACTB_t;
/* High Resolution Enable select */
typedef enum TCE_HREN_enum
{
TCE_HREN_OFF_gc = (0x00<<6), /* High Resolution Disable */
TCE_HREN_4X_gc = (0x01<<6), /* Resolution increased by 4 (2 bits) */
TCE_HREN_8X_gc = (0x02<<6) /* Resolution increased by 4 (3 bits) */
} TCE_HREN_t;
/* Scaled Write select */
typedef enum TCE_SCALE_enum
{
TCE_SCALE_NORMAL_gc = (0x00<<2), /* Absolute values used when writing to CMPn, CMPnBUF and registers */
TCE_SCALE_FRACTIONAL_gc = (0x01<<2) /* Fractional values used when writing to CMPn, CMPnBUF and registers */
} TCE_SCALE_t;
/* Scaling Mode select */
typedef enum TCE_SCALEMODE_enum
{
TCE_SCALEMODE_CENTER_gc = (0x00<<4), /* CMPn registers scaled vs center (50% duty cycle) */
TCE_SCALEMODE_BOTTOM_gc = (0x01<<4), /* CMPn registers scaled vs BOTTOM (0% duty cycle) */
TCE_SCALEMODE_TOP_gc = (0x02<<4), /* CMPn registers scaled vs TOP (100% duty cycle) */
TCE_SCALEMODE_TOPBOTTOM_gc = (0x03<<4) /* CMPn registers scaled vs TOP or BOTTOM depending on written value. */
} TCE_SCALEMODE_t;
/* Waveform generation mode select */
typedef enum TCE_WGMODE_enum
{
TCE_WGMODE_NORMAL_gc = (0x00<<0), /* Normal Mode */
TCE_WGMODE_FRQ_gc = (0x01<<0), /* Frequency Generation Mode */
TCE_WGMODE_SINGLESLOPE_gc = (0x03<<0), /* Single Slope PWM */
TCE_WGMODE_DSTOP_gc = (0x05<<0), /* Dual Slope PWM, overflow on TOP */
TCE_WGMODE_DSBOTH_gc = (0x06<<0), /* Dual Slope PWM, overflow on TOP and BOTTOM */
TCE_WGMODE_DSBOTTOM_gc = (0x07<<0) /* Dual Slope PWM, overflow on BOTTOM */
} TCE_WGMODE_t;
/* TCE - 16-bit Timer/Counter Type E */
/* TCE.CTRLA bit masks and bit positions */
#define TCE_ENABLE_bm 0x01 /* Module Enable bit mask. */
#define TCE_ENABLE_bp 0 /* Module Enable bit position. */
#define TCE_CLKSEL_gm 0x0E /* Clock Selection group mask. */
#define TCE_CLKSEL_gp 1 /* Clock Selection group position. */
#define TCE_CLKSEL_0_bm (1<<1) /* Clock Selection bit 0 mask. */
#define TCE_CLKSEL_0_bp 1 /* Clock Selection bit 0 position. */
#define TCE_CLKSEL_1_bm (1<<2) /* Clock Selection bit 1 mask. */
#define TCE_CLKSEL_1_bp 2 /* Clock Selection bit 1 position. */
#define TCE_CLKSEL_2_bm (1<<3) /* Clock Selection bit 2 mask. */
#define TCE_CLKSEL_2_bp 3 /* Clock Selection bit 2 position. */
#define TCE_RUNSTDBY_bm 0x80 /* Run in Standby bit mask. */
#define TCE_RUNSTDBY_bp 7 /* Run in Standby bit position. */
/* TCE.CTRLB bit masks and bit positions */
#define TCE_WGMODE_gm 0x07 /* Waveform generation mode group mask. */
#define TCE_WGMODE_gp 0 /* Waveform generation mode group position. */
#define TCE_WGMODE_0_bm (1<<0) /* Waveform generation mode bit 0 mask. */
#define TCE_WGMODE_0_bp 0 /* Waveform generation mode bit 0 position. */
#define TCE_WGMODE_1_bm (1<<1) /* Waveform generation mode bit 1 mask. */
#define TCE_WGMODE_1_bp 1 /* Waveform generation mode bit 1 position. */
#define TCE_WGMODE_2_bm (1<<2) /* Waveform generation mode bit 2 mask. */
#define TCE_WGMODE_2_bp 2 /* Waveform generation mode bit 2 position. */
#define TCE_ALUPD_bm 0x08 /* Auto Lock Update bit mask. */
#define TCE_ALUPD_bp 3 /* Auto Lock Update bit position. */
#define TCE_CMP0EN_bm 0x10 /* Compare 0 Enable bit mask. */
#define TCE_CMP0EN_bp 4 /* Compare 0 Enable bit position. */
#define TCE_CMP1EN_bm 0x20 /* Compare 1 Enable bit mask. */
#define TCE_CMP1EN_bp 5 /* Compare 1 Enable bit position. */
#define TCE_CMP2EN_bm 0x40 /* Compare 2 Enable bit mask. */
#define TCE_CMP2EN_bp 6 /* Compare 2 Enable bit position. */
#define TCE_CMP3EN_bm 0x80 /* Compare 3 Enable bit mask. */
#define TCE_CMP3EN_bp 7 /* Compare 3 Enable bit position. */
/* TCE.CTRLC bit masks and bit positions */
#define TCE_CMP0OV_bm 0x01 /* Compare 0 Waveform Output Value bit mask. */
#define TCE_CMP0OV_bp 0 /* Compare 0 Waveform Output Value bit position. */
#define TCE_CMP1OV_bm 0x02 /* Compare 1 Waveform Output Value bit mask. */
#define TCE_CMP1OV_bp 1 /* Compare 1 Waveform Output Value bit position. */
#define TCE_CMP2OV_bm 0x04 /* Compare 2 Waveform Output Value bit mask. */
#define TCE_CMP2OV_bp 2 /* Compare 2 Waveform Output Value bit position. */
#define TCE_CMP3OV_bm 0x08 /* Compare 3 Waveform Output Value bit mask. */
#define TCE_CMP3OV_bp 3 /* Compare 3 Waveform Output Value bit position. */
#define TCE_CMP0POL_bm 0x10 /* Compare 0 Polarity bit mask. */
#define TCE_CMP0POL_bp 4 /* Compare 0 Polarity bit position. */
#define TCE_CMP1POL_bm 0x20 /* Compare 1 Polarity bit mask. */
#define TCE_CMP1POL_bp 5 /* Compare 1 Polarity bit position. */
#define TCE_CMP2POL_bm 0x40 /* Compare 2 Polarity bit mask. */
#define TCE_CMP2POL_bp 6 /* Compare 2 Polarity bit position. */
#define TCE_CMP3POL_bm 0x80 /* Compare 3 Polarity bit mask. */
#define TCE_CMP3POL_bp 7 /* Compare 3 Polarity bit position. */
/* TCE.CTRLD bit masks and bit positions */
#define TCE_SCALE_bm 0x04 /* Scaled Write bit mask. */
#define TCE_SCALE_bp 2 /* Scaled Write bit position. */
#define TCE_AMPEN_bm 0x08 /* Amplitude Control Enable bit mask. */
#define TCE_AMPEN_bp 3 /* Amplitude Control Enable bit position. */
#define TCE_SCALEMODE_gm 0x30 /* Scaling Mode group mask. */
#define TCE_SCALEMODE_gp 4 /* Scaling Mode group position. */
#define TCE_SCALEMODE_0_bm (1<<4) /* Scaling Mode bit 0 mask. */
#define TCE_SCALEMODE_0_bp 4 /* Scaling Mode bit 0 position. */
#define TCE_SCALEMODE_1_bm (1<<5) /* Scaling Mode bit 1 mask. */
#define TCE_SCALEMODE_1_bp 5 /* Scaling Mode bit 1 position. */
#define TCE_HREN_gm 0xC0 /* High Resolution Enable group mask. */
#define TCE_HREN_gp 6 /* High Resolution Enable group position. */
#define TCE_HREN_0_bm (1<<6) /* High Resolution Enable bit 0 mask. */
#define TCE_HREN_0_bp 6 /* High Resolution Enable bit 0 position. */
#define TCE_HREN_1_bm (1<<7) /* High Resolution Enable bit 1 mask. */
#define TCE_HREN_1_bp 7 /* High Resolution Enable bit 1 position. */
/* TCE.CTRLECLR bit masks and bit positions */
#define TCE_DIR_bm 0x01 /* Direction bit mask. */
#define TCE_DIR_bp 0 /* Direction bit position. */
#define TCE_LUPD_bm 0x02 /* Lock Update bit mask. */
#define TCE_LUPD_bp 1 /* Lock Update bit position. */
#define TCE_CMD_gm 0x0C /* Command group mask. */
#define TCE_CMD_gp 2 /* Command group position. */
#define TCE_CMD_0_bm (1<<2) /* Command bit 0 mask. */
#define TCE_CMD_0_bp 2 /* Command bit 0 position. */
#define TCE_CMD_1_bm (1<<3) /* Command bit 1 mask. */
#define TCE_CMD_1_bp 3 /* Command bit 1 position. */
/* TCE.CTRLESET bit masks and bit positions */
/* TCE_DIR is already defined. */
/* TCE_LUPD is already defined. */
/* TCE_CMD is already defined. */
/* TCE.CTRLFCLR bit masks and bit positions */
#define TCE_PERBV_bm 0x01 /* Period Buffer Valid bit mask. */
#define TCE_PERBV_bp 0 /* Period Buffer Valid bit position. */
#define TCE_CMP0BV_bm 0x02 /* Compare 0 Buffer Valid bit mask. */
#define TCE_CMP0BV_bp 1 /* Compare 0 Buffer Valid bit position. */
#define TCE_CMP1BV_bm 0x04 /* Compare 1 Buffer Valid bit mask. */
#define TCE_CMP1BV_bp 2 /* Compare 1 Buffer Valid bit position. */
#define TCE_CMP2BV_bm 0x08 /* Compare 2 Buffer Valid bit mask. */
#define TCE_CMP2BV_bp 3 /* Compare 2 Buffer Valid bit position. */
#define TCE_CMP3BV_bm 0x10 /* Compare 3 Buffer Valid bit mask. */
#define TCE_CMP3BV_bp 4 /* Compare 3 Buffer Valid bit position. */
/* TCE.CTRLFSET bit masks and bit positions */
/* TCE_PERBV is already defined. */
/* TCE_CMP0BV is already defined. */
/* TCE_CMP1BV is already defined. */
/* TCE_CMP2BV is already defined. */
/* TCE_CMP3BV is already defined. */
/* TCE.EVGENCTRL bit masks and bit positions */
#define TCE_CMP0EV_bm 0x10 /* Compare 0 Event bit mask. */
#define TCE_CMP0EV_bp 4 /* Compare 0 Event bit position. */
#define TCE_CMP1EV_bm 0x20 /* Compare 1 Event bit mask. */
#define TCE_CMP1EV_bp 5 /* Compare 1 Event bit position. */
#define TCE_CMP2EV_bm 0x40 /* Compare 2 Event bit mask. */
#define TCE_CMP2EV_bp 6 /* Compare 2 Event bit position. */
#define TCE_CMP3EV_bm 0x80 /* Compare 3 Event bit mask. */
#define TCE_CMP3EV_bp 7 /* Compare 3 Event bit position. */
/* TCE.EVCTRL bit masks and bit positions */
#define TCE_CNTAEI_bm 0x01 /* Count on Event Input A bit mask. */
#define TCE_CNTAEI_bp 0 /* Count on Event Input A bit position. */
#define TCE_EVACTA_gm 0x0E /* Event Action A group mask. */
#define TCE_EVACTA_gp 1 /* Event Action A group position. */
#define TCE_EVACTA_0_bm (1<<1) /* Event Action A bit 0 mask. */
#define TCE_EVACTA_0_bp 1 /* Event Action A bit 0 position. */
#define TCE_EVACTA_1_bm (1<<2) /* Event Action A bit 1 mask. */
#define TCE_EVACTA_1_bp 2 /* Event Action A bit 1 position. */
#define TCE_EVACTA_2_bm (1<<3) /* Event Action A bit 2 mask. */
#define TCE_EVACTA_2_bp 3 /* Event Action A bit 2 position. */
#define TCE_CNTBEI_bm 0x10 /* Count on Event Input B bit mask. */
#define TCE_CNTBEI_bp 4 /* Count on Event Input B bit position. */
#define TCE_EVACTB_gm 0xE0 /* Event Action B group mask. */
#define TCE_EVACTB_gp 5 /* Event Action B group position. */
#define TCE_EVACTB_0_bm (1<<5) /* Event Action B bit 0 mask. */
#define TCE_EVACTB_0_bp 5 /* Event Action B bit 0 position. */
#define TCE_EVACTB_1_bm (1<<6) /* Event Action B bit 1 mask. */
#define TCE_EVACTB_1_bp 6 /* Event Action B bit 1 position. */
#define TCE_EVACTB_2_bm (1<<7) /* Event Action B bit 2 mask. */
#define TCE_EVACTB_2_bp 7 /* Event Action B bit 2 position. */
/* TCE.INTCTRL bit masks and bit positions */
#define TCE_OVF_bm 0x01 /* Overflow Interrupt Enable bit mask. */
#define TCE_OVF_bp 0 /* Overflow Interrupt Enable bit position. */
#define TCE_CMP0_bm 0x10 /* Compare 0 Interrupt Enable bit mask. */
#define TCE_CMP0_bp 4 /* Compare 0 Interrupt Enable bit position. */
#define TCE_CMP1_bm 0x20 /* Compare 1 Interrupt Enable bit mask. */
#define TCE_CMP1_bp 5 /* Compare 1 Interrupt Enable bit position. */
#define TCE_CMP2_bm 0x40 /* Compare 2 Interrupt Enable bit mask. */
#define TCE_CMP2_bp 6 /* Compare 2 Interrupt Enable bit position. */
#define TCE_CMP3_bm 0x80 /* Compare 3 Interrupt Enable bit mask. */
#define TCE_CMP3_bp 7 /* Compare 3 Interrupt Enable bit position. */
/* TCE.INTFLAGS bit masks and bit positions */
/* TCE_OVF is already defined. */
/* TCE_CMP0 is already defined. */
/* TCE_CMP1 is already defined. */
/* TCE_CMP2 is already defined. */
/* TCE_CMP3 is already defined. */
/* TCE.DBGCTRL bit masks and bit positions */
#define TCE_DBGRUN_bm 0x01 /* Debug Run bit mask. */
#define TCE_DBGRUN_bp 0 /* Debug Run bit position. */ Well, I suppose this is consistent with one of the scenarios predicted for the new functionality: It looks very much like a TCA, only expanded with a 4th channel, and giving up split mode (that part is quite sad). But there's clearly some wacky shit above and beyond that! Well beyond that. TCF /*
--------------------------------------------------------------------------
TCF - 24-bit Timer/Counter for frequency generation
--------------------------------------------------------------------------
*/
/* 24-bit Timer/Counter for frequency generation */
typedef struct TCF_struct
{
register8_t CTRLA; /* Control A */
register8_t CTRLB; /* Control B */
register8_t CTRLC; /* Control C */
register8_t CTRLD; /* Control D */
register8_t EVCTRL; /* Event Control */
register8_t INTCTRL; /* Interrupt Control */
register8_t INTFLAGS; /* Interrupt Flags */
register8_t STATUS; /* Status */
register8_t reserved_1[5];
register8_t DBGCTRL; /* Debug Control */
register8_t reserved_2[2];
_DWORDREGISTER(CNT); /* Count */
_DWORDREGISTER(CMP); /* Compare */
register8_t reserved_3[8];
} TCF_t;
/* Clock Select */
typedef enum TCF_CLKSEL_enum
{
TCF_CLKSEL_CLKPER_gc = (0x00<<3), /* Peripheral Clock */
TCF_CLKSEL_EVENT_gc = (0x01<<3), /* Event as clock source */
TCF_CLKSEL_OSCHF_gc = (0x02<<3), /* Internal High Frequency Oscillator */
TCF_CLKSEL_OSC32K_gc = (0x03<<3), /* Internal 32.768 kHz Oscillator */
TCF_CLKSEL_PLL_gc = (0x05<<3) /* PLL */
} TCF_CLKSEL_t;
/* Command select */
typedef enum TCF_CMD_enum
{
TCF_CMD_NONE_gc = (0x00<<0), /* No command */
TCF_CMD_UPDATE_gc = (0x01<<0), /* Force update */
TCF_CMD_RESTART_gc = (0x02<<0) /* Force restart */
} TCF_CMD_t;
/* Compare # Event Generation select */
typedef enum TCF_CMP0EV_enum
{
TCF_CMP0EV_PULSE_gc = (0x00<<6), /* Event is generated as pulse */
TCF_CMP0EV_WAVEFORM_gc = (0x01<<6) /* Waveform is used as event output */
} TCF_CMP0EV_t;
/* Compare # Event Generation select */
typedef enum TCF_CMP1EV_enum
{
TCF_CMP1EV_PULSE_gc = (0x00<<7), /* Event is generated as pulse */
TCF_CMP1EV_WAVEFORM_gc = (0x01<<7) /* Waveform is used as event output */
} TCF_CMP1EV_t;
/* Event Action A select */
typedef enum TCF_EVACTA_enum
{
TCF_EVACTA_RESTART_gc = (0x00<<1), /* Restart Counter */
TCF_EVACTA_BLANK_gc = (0x01<<1) /* Mask waveform output to '0' */
} TCF_EVACTA_t;
/* Clock Prescaler select */
typedef enum TCF_PRESC_enum
{
TCF_PRESC_DIV1_gc = (0x00<<1), /* Runs directly on Clock Source */
TCF_PRESC_DIV2_gc = (0x01<<1), /* Divide clock source by 2 */
TCF_PRESC_DIV4_gc = (0x02<<1), /* Divide clock source by 4 */
TCF_PRESC_DIV8_gc = (0x03<<1), /* Divide clock source by 8 */
TCF_PRESC_DIV16_gc = (0x04<<1), /* Divide clock source by 16 */
TCF_PRESC_DIV32_gc = (0x05<<1), /* Divide clock source by 32 */
TCF_PRESC_DIV64_gc = (0x06<<1), /* Divide clock source by 64 */
TCF_PRESC_DIV128_gc = (0x07<<1) /* Divide clock source by 128 */
} TCF_PRESC_t;
/* Waveform Generation Mode select */
typedef enum TCF_WGMODE_enum
{
TCF_WGMODE_FRQ_gc = (0x00<<0), /* Frequency */
TCF_WGMODE_NCOPF_gc = (0x01<<0), /* Numerically Controlled Oscillator Pulse-Frequency */
TCF_WGMODE_NCOFDC_gc = (0x02<<0), /* Numerically Controlled Oscillator Fixed Duty Cycle */
TCF_WGMODE_PWM8_gc = (0x07<<0) /* 8-bit PWM */
} TCF_WGMODE_t;
/* Waveform Generation Pulse Length select */
typedef enum TCF_WGPULSE_enum
{
TCF_WGPULSE_CLK1_gc = (0x00<<4), /* High pulse duration is 1 clock period */
TCF_WGPULSE_CLK2_gc = (0x01<<4), /* High pulse duration is 2 clock period */
TCF_WGPULSE_CLK4_gc = (0x02<<4), /* High pulse duration is 4 clock period */
TCF_WGPULSE_CLK8_gc = (0x03<<4), /* High pulse duration is 8 clock period */
TCF_WGPULSE_CLK16_gc = (0x04<<4), /* High pulse duration is 16 clock period */
TCF_WGPULSE_CLK32_gc = (0x05<<4), /* High pulse duration is 32 clock period */
TCF_WGPULSE_CLK64_gc = (0x06<<4), /* High pulse duration is 64 clock period */
TCF_WGPULSE_CLK128_gc = (0x07<<4) /* High pulse duration is 128 clock period */
} TCF_WGPULSE_t;
/* Waveform Output # Polarity select */
typedef enum TCF_WO0POL_enum
{
TCF_WO0POL_NORMAL_gc = (0x00<<2), /* Waveform output set on update and cleared on match */
TCF_WO0POL_INVERSE_gc = (0x01<<2) /* Waveform output cleared on update and set on match */
} TCF_WO0POL_t;
/* Waveform Output # Polarity select */
typedef enum TCF_WO1POL_enum
{
TCF_WO1POL_NORMAL_gc = (0x00<<3), /* Waveform output set on update and cleared on match */
TCF_WO1POL_INVERSE_gc = (0x01<<3) /* Waveform output cleared on update and set on match */
} TCF_WO1POL_t;
/* TCF - 24-bit Timer/Counter for frequency generation */
/* TCF.CTRLA bit masks and bit positions */
#define TCF_ENABLE_bm 0x01 /* Enable bit mask. */
#define TCF_ENABLE_bp 0 /* Enable bit position. */
#define TCF_PRESC_gm 0x0E /* Clock Prescaler group mask. */
#define TCF_PRESC_gp 1 /* Clock Prescaler group position. */
#define TCF_PRESC_0_bm (1<<1) /* Clock Prescaler bit 0 mask. */
#define TCF_PRESC_0_bp 1 /* Clock Prescaler bit 0 position. */
#define TCF_PRESC_1_bm (1<<2) /* Clock Prescaler bit 1 mask. */
#define TCF_PRESC_1_bp 2 /* Clock Prescaler bit 1 position. */
#define TCF_PRESC_2_bm (1<<3) /* Clock Prescaler bit 2 mask. */
#define TCF_PRESC_2_bp 3 /* Clock Prescaler bit 2 position. */
#define TCF_RUNSTDBY_bm 0x80 /* Run Standby bit mask. */
#define TCF_RUNSTDBY_bp 7 /* Run Standby bit position. */
/* TCF.CTRLB bit masks and bit positions */
#define TCF_WGMODE_gm 0x07 /* Waveform Generation Mode group mask. */
#define TCF_WGMODE_gp 0 /* Waveform Generation Mode group position. */
#define TCF_WGMODE_0_bm (1<<0) /* Waveform Generation Mode bit 0 mask. */
#define TCF_WGMODE_0_bp 0 /* Waveform Generation Mode bit 0 position. */
#define TCF_WGMODE_1_bm (1<<1) /* Waveform Generation Mode bit 1 mask. */
#define TCF_WGMODE_1_bp 1 /* Waveform Generation Mode bit 1 position. */
#define TCF_WGMODE_2_bm (1<<2) /* Waveform Generation Mode bit 2 mask. */
#define TCF_WGMODE_2_bp 2 /* Waveform Generation Mode bit 2 position. */
#define TCF_CLKSEL_gm 0x38 /* Clock Select group mask. */
#define TCF_CLKSEL_gp 3 /* Clock Select group position. */
#define TCF_CLKSEL_0_bm (1<<3) /* Clock Select bit 0 mask. */
#define TCF_CLKSEL_0_bp 3 /* Clock Select bit 0 position. */
#define TCF_CLKSEL_1_bm (1<<4) /* Clock Select bit 1 mask. */
#define TCF_CLKSEL_1_bp 4 /* Clock Select bit 1 position. */
#define TCF_CLKSEL_2_bm (1<<5) /* Clock Select bit 2 mask. */
#define TCF_CLKSEL_2_bp 5 /* Clock Select bit 2 position. */
#define TCF_CMP0EV_bm 0x40 /* Compare 0 Event Generation bit mask. */
#define TCF_CMP0EV_bp 6 /* Compare 0 Event Generation bit position. */
#define TCF_CMP1EV_bm 0x80 /* Compare 1 Event Generation bit mask. */
#define TCF_CMP1EV_bp 7 /* Compare 1 Event Generation bit position. */
/* TCF.CTRLC bit masks and bit positions */
#define TCF_WO0EN_bm 0x01 /* Waveform Output 0 Enable bit mask. */
#define TCF_WO0EN_bp 0 /* Waveform Output 0 Enable bit position. */
#define TCF_WO1EN_bm 0x02 /* Waveform Output 1 Enable bit mask. */
#define TCF_WO1EN_bp 1 /* Waveform Output 1 Enable bit position. */
#define TCF_WO0POL_bm 0x04 /* Waveform Output 0 Polarity bit mask. */
#define TCF_WO0POL_bp 2 /* Waveform Output 0 Polarity bit position. */
#define TCF_WO1POL_bm 0x08 /* Waveform Output 1 Polarity bit mask. */
#define TCF_WO1POL_bp 3 /* Waveform Output 1 Polarity bit position. */
#define TCF_WGPULSE_gm 0x70 /* Waveform Generation Pulse Length group mask. */
#define TCF_WGPULSE_gp 4 /* Waveform Generation Pulse Length group position. */
#define TCF_WGPULSE_0_bm (1<<4) /* Waveform Generation Pulse Length bit 0 mask. */
#define TCF_WGPULSE_0_bp 4 /* Waveform Generation Pulse Length bit 0 position. */
#define TCF_WGPULSE_1_bm (1<<5) /* Waveform Generation Pulse Length bit 1 mask. */
#define TCF_WGPULSE_1_bp 5 /* Waveform Generation Pulse Length bit 1 position. */
#define TCF_WGPULSE_2_bm (1<<6) /* Waveform Generation Pulse Length bit 2 mask. */
#define TCF_WGPULSE_2_bp 6 /* Waveform Generation Pulse Length bit 2 position. */
/* TCF.CTRLD bit masks and bit positions */
#define TCF_CMD_gm 0x03 /* Command group mask. */
#define TCF_CMD_gp 0 /* Command group position. */
#define TCF_CMD_0_bm (1<<0) /* Command bit 0 mask. */
#define TCF_CMD_0_bp 0 /* Command bit 0 position. */
#define TCF_CMD_1_bm (1<<1) /* Command bit 1 mask. */
#define TCF_CMD_1_bp 1 /* Command bit 1 position. */
/* TCF.EVCTRL bit masks and bit positions */
#define TCF_CNTAEI_bm 0x01 /* Event A Input Enable bit mask. */
#define TCF_CNTAEI_bp 0 /* Event A Input Enable bit position. */
#define TCF_EVACTA_gm 0x06 /* Event Action A group mask. */
#define TCF_EVACTA_gp 1 /* Event Action A group position. */
#define TCF_EVACTA_0_bm (1<<1) /* Event Action A bit 0 mask. */
#define TCF_EVACTA_0_bp 1 /* Event Action A bit 0 position. */
#define TCF_EVACTA_1_bm (1<<2) /* Event Action A bit 1 mask. */
#define TCF_EVACTA_1_bp 2 /* Event Action A bit 1 position. */
#define TCF_FILTERA_bm 0x08 /* Event A Filter bit mask. */
#define TCF_FILTERA_bp 3 /* Event A Filter bit position. */
/* TCF.INTCTRL bit masks and bit positions */
#define TCF_OVF_bm 0x01 /* Overflow bit mask. */
#define TCF_OVF_bp 0 /* Overflow bit position. */
#define TCF_CMP0_bm 0x02 /* Compare 0 Interrupt Enable bit mask. */
#define TCF_CMP0_bp 1 /* Compare 0 Interrupt Enable bit position. */
#define TCF_CMP1_bm 0x04 /* Compare 1 Interrupt Enable bit mask. */
#define TCF_CMP1_bp 2 /* Compare 1 Interrupt Enable bit position. */
/* TCF.INTFLAGS bit masks and bit positions */
/* TCF_OVF is already defined. */
/* TCF_CMP0 is already defined. */
/* TCF_CMP1 is already defined. */
/* TCF.STATUS bit masks and bit positions */
#define TCF_CTRLABUSY_bm 0x02 /* Control A Synchronization Busy bit mask. */
#define TCF_CTRLABUSY_bp 1 /* Control A Synchronization Busy bit position. */
#define TCF_CTRLCBUSY_bm 0x04 /* Control B Synchronization Busy bit mask. */
#define TCF_CTRLCBUSY_bp 2 /* Control B Synchronization Busy bit position. */
#define TCF_CTRLDBUSY_bm 0x08 /* Control D Synchronization Busy bit mask. */
#define TCF_CTRLDBUSY_bp 3 /* Control D Synchronization Busy bit position. */
#define TCF_CNTBUSY_bm 0x10 /* Counter Synchronization Busy bit mask. */
#define TCF_CNTBUSY_bp 4 /* Counter Synchronization Busy bit position. */
#define TCF_PERBUSY_bm 0x20 /* Period Synchronization Busy bit mask. */
#define TCF_PERBUSY_bp 5 /* Period Synchronization Busy bit position. */
#define TCF_CMP0BUSY_bm 0x40 /* Compare 0 Synchronization Busy bit mask. */
#define TCF_CMP0BUSY_bp 6 /* Compare 0 Synchronization Busy bit position. */
#define TCF_CMP1BUSY_bm 0x80 /* Compare 1 Synchronization Busy bit mask. */
#define TCF_CMP1BUSY_bp 7 /* Compare 1 Synchronization Busy bit position. */
/* TCF.DBGCTRL bit masks and bit positions */
#define TCF_DBGRUN_bm 0x01 /* Debug Run bit mask. */
#define TCF_DBGRUN_bp 0 /* Debug Run bit position. */
/* TCF.CNT - 24 bit register!
/* TCF.CMP - 24 bit register! Yes, It is 24 bit! The nature of it's capabilities are somewhat unclear though. It seems really wacky. I wonder what Numerically Controlled Oscillator Pulse-Frequency and Numerically Controlled Oscillator Fixed Duty Cycle modes are. As expected., we have a PLL capable of running well above the CPU speed in order to make a 24 bit timer make sense, but the other modes raise more questions than answers. /*
--------------------------------------------------------------------------
WEX - Waveform Extension
--------------------------------------------------------------------------
*/
/* Waveform Extension */
typedef struct WEX_struct
{
register8_t CTRLA; /* Control A */
register8_t CTRLB; /* Control B */
register8_t CTRLC; /* Control C */
register8_t reserved_1[1];
register8_t EVCTRLA; /* Event Control A */
register8_t EVCTRLB; /* Event Control B */
register8_t EVCTRLC; /* Event Control C */
register8_t BUFCTRL; /* Buffer Valid Control */
register8_t BLANKCTRL; /* Blanking Control */
register8_t BLANKTIME; /* Blanking Time */
register8_t FAULTCTRL; /* Fault Control */
register8_t FAULTDRV; /* Fault Drive */
register8_t FAULTOUT; /* Fault Output */
register8_t INTCTRL; /* Interrupt Control */
register8_t INTFLAGS; /* Interrupt Flags */
register8_t STATUS; /* Status */
register8_t DTLS; /* Dead-time Low Side */
register8_t DTHS; /* Dead-time High Side */
register8_t DTBOTH; /* Dead-time Both Sides */
register8_t SWAP; /* DTI Swap */
register8_t PGMOVR; /* Pattern Generation Override */
register8_t PGMOUT; /* Pattern Generation Output */
register8_t reserved_2[1];
register8_t OUTOVEN; /* Output Override Enable */
register8_t DTLSBUF; /* Dead-time Low Side Buffer */
register8_t DTHSBUF; /* Dead-time High Side Buffer */
register8_t DTBOTHBUF; /* Dead-time Both Sides Buffer */
register8_t SWAPBUF; /* DTI Swap Buffer */
register8_t PGMOVRBUF; /* Pattern Generation Override Buffer */
register8_t PGMOUTBUF; /* Pattern Generation Output Buffer */
register8_t reserved_3[2];
} WEX_t;
/* Blanking Prescaler select */
typedef enum WEX_BLANKPRESC_enum
{
WEX_BLANKPRESC_DIV1_gc = (0x00<<5), /* No prescaling */
WEX_BLANKPRESC_DIV4_gc = (0x01<<5), /* Divide CLK_PER by 4 */
WEX_BLANKPRESC_DIV16_gc = (0x02<<5), /* Divide CLK_PER by 16 */
WEX_BLANKPRESC_DIV64_gc = (0x03<<5) /* Divide CLK_PER by 64 */
} WEX_BLANKPRESC_t;
/* Blanking Trigger Source select */
typedef enum WEX_BLANKSRC_enum
{
WEX_BLANKSRC_TCPWM0_gc = (0x00<<0) /* TCPWM0 */
} WEX_BLANKSRC_t;
/* Blanking State select */
typedef enum WEX_BLANKSTATE_enum
{
WEX_BLANKSTATE_OFF_gc = (0x00<<7), /* Blanking off */
WEX_BLANKSTATE_ON_gc = (0x01<<7) /* Blanking active */
} WEX_BLANKSTATE_t;
/* Blanking Trigger select */
typedef enum WEX_BLANKTRIG_enum
{
WEX_BLANKTRIG_NONE_gc = (0x00<<2), /* No HW blanking trigger. SW blanking only */
WEX_BLANKTRIG_UPDATE_gc = (0x01<<2), /* T/C Update Condition */
WEX_BLANKTRIG_CMP0_gc = (0x02<<2), /* Compare Match 0 */
WEX_BLANKTRIG_CMP1_gc = (0x03<<2), /* Compare Match 1 */
WEX_BLANKTRIG_CMP2_gc = (0x04<<2), /* Compare Match 2 */
WEX_BLANKTRIG_CMP3_gc = (0x05<<2) /* Compare Match 3 */
} WEX_BLANKTRIG_t;
/* Command select */
typedef enum WEX_CMD_enum
{
WEX_CMD_NONE_gc = (0x00<<0), /* No Command */
WEX_CMD_UPDATE_gc = (0x01<<0), /* Force update of Dead-time, SWAP and PGM buffer registers. */
WEX_CMD_FAULTSET_gc = (0x02<<0), /* Set Fault Detection */
WEX_CMD_FAULTCLR_gc = (0x03<<0), /* Clear Fault Detection. */
WEX_CMD_BLANKSET_gc = (0x04<<0), /* Set SW Blanking */
WEX_CMD_BLANKCLR_gc = (0x05<<0) /* Clear SW Blanking */
} WEX_CMD_t;
/* Fault Detection Action select */
typedef enum WEX_FDACT_enum
{
WEX_FDACT_NONE_gc = (0x00<<0), /* None. Fault Protection Disabled */
WEX_FDACT_LOW_gc = (0x01<<0), /* Drive all pins low */
WEX_FDACT_CUSTOM_gc = (0x03<<0) /* Drive all pins to setting defined by FAULTDRV and FAULTVAL */
} WEX_FDACT_t;
/* Fault Detection on Debug Break Detection select */
typedef enum WEX_FDDBD_enum
{
WEX_FDDBD_FAULT_gc = (0x00<<7), /* OCD Break request is treated as a fault if fault protection is enabled */
WEX_FDDBD_IGNORE_gc = (0x01<<7) /* OCD Breask request will not trigger a fault */
} WEX_FDDBD_t;
/* Fault Detection Restart Mode select */
typedef enum WEX_FDMODE_enum
{
WEX_FDMODE_LATCHED_gc = (0x00<<2), /* Latched Mode. Output will remain in fault state until fault condition is no longer active and FDF is cleared by SW. */
WEX_FDMODE_CBC_gc = (0x01<<2) /* Cycle-by-cycle mode. Waveform output will remain in fault state until fault condition is no longer active. */
} WEX_FDMODE_t;
/* Fault Detection State select */
typedef enum WEX_FDSTATE_enum
{
WEX_FDSTATE_NORMAL_gc = (0x00<<0), /* Normal state */
WEX_FDSTATE_FAULT_gc = (0x01<<0) /* Fault state */
} WEX_FDSTATE_t;
/* Fault Event Filter Enable select */
typedef enum WEX_FILTER_enum
{
WEX_FILTER_ZERO_gc = (0x00<<2), /* No digital filter */
WEX_FILTER_SAMPLE1_gc = (0x01<<2), /* One Sample */
WEX_FILTER_SAMPLE2_gc = (0x02<<2), /* Two Samples */
WEX_FILTER_SAMPLE3_gc = (0x03<<2), /* Three Samples */
WEX_FILTER_SAMPLE4_gc = (0x04<<2), /* Four Samples */
WEX_FILTER_SAMPLE5_gc = (0x05<<2), /* Five Samples */
WEX_FILTER_SAMPLE6_gc = (0x06<<2), /* Six Samples */
WEX_FILTER_SAMPLE7_gc = (0x07<<2) /* Seven Samples */
} WEX_FILTER_t;
/* Input Matrix select */
typedef enum WEX_INMX_enum
{
WEX_INMX_DIRECT_gc = (0x00<<4), /* Direct from TCE0 */
WEX_INMX_CWCMA_gc = (0x02<<4), /* Common Waveform Channel Mode A. Single WO */
WEX_INMX_CWCMB_gc = (0x03<<4) /* Common Waveform Channel Mode B. WO from two PWM channels */
} WEX_INMX_t;
/* Update Source select */
typedef enum WEX_UPDSRC_enum
{
WEX_UPDSRC_TCPWM0_gc = (0x00<<0), /* Timer/Counter for PWM 0 update condition */
WEX_UPDSRC_NONE_gc = (0x03<<0) /* No hardware update condition */
} WEX_UPDSRC_t;
/* WEX - Waveform Extension */
/* WEX.CTRLA bit masks and bit positions */
#define WEX_DTI0EN_bm 0x01 /* Dead-Time Insertion CMP0 Enable bit mask. */
#define WEX_DTI0EN_bp 0 /* Dead-Time Insertion CMP0 Enable bit position. */
#define WEX_DTI1EN_bm 0x02 /* Dead-Time Insertion CMP1 Enable bit mask. */
#define WEX_DTI1EN_bp 1 /* Dead-Time Insertion CMP1 Enable bit position. */
#define WEX_DTI2EN_bm 0x04 /* Dead-Time Insertion CMP2 Enable bit mask. */
#define WEX_DTI2EN_bp 2 /* Dead-Time Insertion CMP2 Enable bit position. */
#define WEX_DTI3EN_bm 0x08 /* Dead-Time Insertion CMP3 Enable bit mask. */
#define WEX_DTI3EN_bp 3 /* Dead-Time Insertion CMP3 Enable bit position. */
#define WEX_INMX_gm 0x70 /* Input Matrix group mask. */
#define WEX_INMX_gp 4 /* Input Matrix group position. */
#define WEX_INMX_0_bm (1<<4) /* Input Matrix bit 0 mask. */
#define WEX_INMX_0_bp 4 /* Input Matrix bit 0 position. */
#define WEX_INMX_1_bm (1<<5) /* Input Matrix bit 1 mask. */
#define WEX_INMX_1_bp 5 /* Input Matrix bit 1 position. */
#define WEX_INMX_2_bm (1<<6) /* Input Matrix bit 2 mask. */
#define WEX_INMX_2_bp 6 /* Input Matrix bit 2 position. */
#define WEX_PGM_bm 0x80 /* Pattern Generation Mode bit mask. */
#define WEX_PGM_bp 7 /* Pattern Generation Mode bit position. */
/* WEX.CTRLB bit masks and bit positions */
#define WEX_UPDSRC_gm 0x03 /* Update Source group mask. */
#define WEX_UPDSRC_gp 0 /* Update Source group position. */
#define WEX_UPDSRC_0_bm (1<<0) /* Update Source bit 0 mask. */
#define WEX_UPDSRC_0_bp 0 /* Update Source bit 0 position. */
#define WEX_UPDSRC_1_bm (1<<1) /* Update Source bit 1 mask. */
#define WEX_UPDSRC_1_bp 1 /* Update Source bit 1 position. */
/* WEX.CTRLC bit masks and bit positions */
#define WEX_CMD_gm 0x07 /* Command group mask. */
#define WEX_CMD_gp 0 /* Command group position. */
#define WEX_CMD_0_bm (1<<0) /* Command bit 0 mask. */
#define WEX_CMD_0_bp 0 /* Command bit 0 position. */
#define WEX_CMD_1_bm (1<<1) /* Command bit 1 mask. */
#define WEX_CMD_1_bp 1 /* Command bit 1 position. */
#define WEX_CMD_2_bm (1<<2) /* Command bit 2 mask. */
#define WEX_CMD_2_bp 2 /* Command bit 2 position. */
/* WEX.EVCTRLA bit masks and bit positions */
#define WEX_FAULTEI_bm 0x01 /* Fault Event Input Enable bit mask. */
#define WEX_FAULTEI_bp 0 /* Fault Event Input Enable bit position. */
#define WEX_BLANK_bm 0x02 /* Fault Event Blanking Enable bit mask. */
#define WEX_BLANK_bp 1 /* Fault Event Blanking Enable bit position. */
#define WEX_FILTER_gm 0x1C /* Fault Event Filter Enable group mask. */
#define WEX_FILTER_gp 2 /* Fault Event Filter Enable group position. */
#define WEX_FILTER_0_bm (1<<2) /* Fault Event Filter Enable bit 0 mask. */
#define WEX_FILTER_0_bp 2 /* Fault Event Filter Enable bit 0 position. */
#define WEX_FILTER_1_bm (1<<3) /* Fault Event Filter Enable bit 1 mask. */
#define WEX_FILTER_1_bp 3 /* Fault Event Filter Enable bit 1 position. */
#define WEX_FILTER_2_bm (1<<4) /* Fault Event Filter Enable bit 2 mask. */
#define WEX_FILTER_2_bp 4 /* Fault Event Filter Enable bit 2 position. */
/* WEX.EVCTRLB bit masks and bit positions */
/* WEX_FAULTEI is already defined. */
/* WEX_BLANK is already defined. */
/* WEX_FILTER is already defined. */
/* WEX.EVCTRLC bit masks and bit positions */
/* WEX_FAULTEI is already defined. */
/* WEX_BLANK is already defined. */
/* WEX_FILTER is already defined. */
/* WEX.BUFCTRL bit masks and bit positions */
#define WEX_DTLSBV_bm 0x01 /* Dead-time Low Side Buffer Valid bit mask. */
#define WEX_DTLSBV_bp 0 /* Dead-time Low Side Buffer Valid bit position. */
#define WEX_DTHSBV_bm 0x02 /* Dead-time High Side Buffer Valid bit mask. */
#define WEX_DTHSBV_bp 1 /* Dead-time High Side Buffer Valid bit position. */
#define WEX_SWAPBV_bm 0x04 /* Swap Buffer Valid bit mask. */
#define WEX_SWAPBV_bp 2 /* Swap Buffer Valid bit position. */
#define WEX_PGMOVRBV_bm 0x08 /* PGM Override Buffer Valid bit mask. */
#define WEX_PGMOVRBV_bp 3 /* PGM Override Buffer Valid bit position. */
#define WEX_PGMOUTBV_bm 0x10 /* PGM Output Value Buffer Valid bit mask. */
#define WEX_PGMOUTBV_bp 4 /* PGM Output Value Buffer Valid bit position. */
/* WEX.BLANKCTRL bit masks and bit positions */
#define WEX_BLANKSRC_bm 0x01 /* Blanking Trigger Source bit mask. */
#define WEX_BLANKSRC_bp 0 /* Blanking Trigger Source bit position. */
#define WEX_BLANKTRIG_gm 0x1C /* Blanking Trigger group mask. */
#define WEX_BLANKTRIG_gp 2 /* Blanking Trigger group position. */
#define WEX_BLANKTRIG_0_bm (1<<2) /* Blanking Trigger bit 0 mask. */
#define WEX_BLANKTRIG_0_bp 2 /* Blanking Trigger bit 0 position. */
#define WEX_BLANKTRIG_1_bm (1<<3) /* Blanking Trigger bit 1 mask. */
#define WEX_BLANKTRIG_1_bp 3 /* Blanking Trigger bit 1 position. */
#define WEX_BLANKTRIG_2_bm (1<<4) /* Blanking Trigger bit 2 mask. */
#define WEX_BLANKTRIG_2_bp 4 /* Blanking Trigger bit 2 position. */
#define WEX_BLANKPRESC_gm 0x60 /* Blanking Prescaler group mask. */
#define WEX_BLANKPRESC_gp 5 /* Blanking Prescaler group position. */
#define WEX_BLANKPRESC_0_bm (1<<5) /* Blanking Prescaler bit 0 mask. */
#define WEX_BLANKPRESC_0_bp 5 /* Blanking Prescaler bit 0 position. */
#define WEX_BLANKPRESC_1_bm (1<<6) /* Blanking Prescaler bit 1 mask. */
#define WEX_BLANKPRESC_1_bp 6 /* Blanking Prescaler bit 1 position. */
/* WEX.FAULTCTRL bit masks and bit positions */
#define WEX_FDACT_gm 0x03 /* Fault Detection Action group mask. */
#define WEX_FDACT_gp 0 /* Fault Detection Action group position. */
#define WEX_FDACT_0_bm (1<<0) /* Fault Detection Action bit 0 mask. */
#define WEX_FDACT_0_bp 0 /* Fault Detection Action bit 0 position. */
#define WEX_FDACT_1_bm (1<<1) /* Fault Detection Action bit 1 mask. */
#define WEX_FDACT_1_bp 1 /* Fault Detection Action bit 1 position. */
#define WEX_FDMODE_bm 0x04 /* Fault Detection Restart Mode bit mask. */
#define WEX_FDMODE_bp 2 /* Fault Detection Restart Mode bit position. */
#define WEX_FDDBD_bm 0x80 /* Fault Detection on Debug Break Detection bit mask. */
#define WEX_FDDBD_bp 7 /* Fault Detection on Debug Break Detection bit position. */
/* WEX.FAULTDRV bit masks and bit positions - 1 byte*/
/* Fault Drive Enable */
/* WEX.FAULTOUT bit masks and bit positions - 1 byte*/
/* Fault Output Value */
/* WEX.INTCTRL bit masks and bit positions */
#define WEX_FAULTDET_bm 0x01 /* Fault Detection Interrupt Enable bit mask. */
#define WEX_FAULTDET_bp 0 /* Fault Detection Interrupt Enable bit position. */
/* WEX.INTFLAGS bit masks and bit positions */
/* WEX_FAULTDET is already defined. */
#define WEX_FDFEVA_bm 0x04 /* Fault Detection Flag Event Input A bit mask. */
#define WEX_FDFEVA_bp 2 /* Fault Detection Flag Event Input A bit position. */
#define WEX_FDFEVB_bm 0x08 /* Fault Detection Flag Event Input B bit mask. */
#define WEX_FDFEVB_bp 3 /* Fault Detection Flag Event Input B bit position. */
#define WEX_FDFEVC_bm 0x10 /* Fault Detection Flag Event Input C bit mask. */
#define WEX_FDFEVC_bp 4 /* Fault Detection Flag Event Input C bit position. */
/* WEX.STATUS bit masks and bit positions */
#define WEX_FDSTATE_bm 0x01 /* Fault Detection State bit mask. */
#define WEX_FDSTATE_bp 0 /* Fault Detection State bit position. */
#define WEX_FDSEVA_bm 0x04 /* Fault Detection State Event A bit mask. */
#define WEX_FDSEVA_bp 2 /* Fault Detection State Event A bit position. */
#define WEX_FDSEVB_bm 0x08 /* Fault Detection State Event B bit mask. */
#define WEX_FDSEVB_bp 3 /* Fault Detection State Event B bit position. */
#define WEX_FDSEVC_bm 0x10 /* Fault Detection State Event C bit mask. */
#define WEX_FDSEVC_bp 4 /* Fault Detection State Event C bit position. */
#define WEX_BLANKSTATE_bm 0x80 /* Blanking State bit mask. */
#define WEX_BLANKSTATE_bp 7 /* Blanking State bit position. */
/* WEX.SWAP bit masks and bit positions */
#define WEX_SWAP0_bm 0x01 /* Swap DTI Output Pair 0 bit mask. */
#define WEX_SWAP0_bp 0 /* Swap DTI Output Pair 0 bit position. */
#define WEX_SWAP1_bm 0x02 /* Swap DTI Output Pair 1 bit mask. */
#define WEX_SWAP1_bp 1 /* Swap DTI Output Pair 1 bit position. */
#define WEX_SWAP2_bm 0x04 /* Swap DTI Output Pair 2 bit mask. */
#define WEX_SWAP2_bp 2 /* Swap DTI Output Pair 2 bit position. */
#define WEX_SWAP3_bm 0x08 /* Swap DTI Output Pair 3 bit mask. */
#define WEX_SWAP3_bp 3 /* Swap DTI Output Pair 3 bit position. */
/* WEX.PGMOVR bit masks and bit positions - 1 byte*/
/* Pattern Generation Override Enable */
/* WEX.PGMOUT bit masks and bit positions - 1 byte*/
/* Pattern Generation Output Value */
/* WEX.OUTOVEN bit masks and bit positions - 1 byte*/
/* Output Override Enable */
/* WEX.SWAPBUF bit masks and bit positions */
#define WEX_SWAPBUF0_bm 0x01 /* Swap DTI Output Pair 0 Buffer bit mask. */
#define WEX_SWAPBUF0_bp 0 /* Swap DTI Output Pair 0 Buffer bit position. */
#define WEX_SWAPBUF1_bm 0x02 /* Swap DTI Output Pair 1 Buffer bit mask. */
#define WEX_SWAPBUF1_bp 1 /* Swap DTI Output Pair 1 Buffer bit position. */
#define WEX_SWAPBUF2_bm 0x04 /* Swap DTI Output Pair 2 Buffer bit mask. */
#define WEX_SWAPBUF2_bp 2 /* Swap DTI Output Pair 2 Buffer bit position. */
#define WEX_SWAPBUF3_bm 0x08 /* Swap DTI Output Pair 3 Buffer bit mask. */
#define WEX_SWAPBUF3_bp 3 /* Swap DTI Output Pair 3 Buffer bit position. */
/* WEX.PGMOVRBUF bit masks and bit positions = 1 byte value. */
/* Pattern Generation Override Enable Buffer */
/* WEX.PGMOUTBUF bit masks and bit positions = 1 byte value. */
/* Pattern Generation Output Value Buffer */ What is this I don't even...... Notice the astonishing number of mysterious 1 byte, 1 bitfield registers. Yeah I don't think WEX has mended his ways.... |
Beta Was this translation helpful? Give feedback.
-
Another gem: CCL_CLKSRC_PLL_gc = (0x07<<1) /* PLL */ Been waiting for that ever since I learned the CCL is async. And we get a very fancy PLL on these parts. |
Beta Was this translation helpful? Give feedback.
-
Stumbled upon a 24-bit timer with WEX in a SAM datasheet: https://ww1.microchip.com/downloads/aemDocuments/documents/MCU32/ProductDocuments/DataSheets/SAM_L21_Family_DataSheet_DS60001477C.pdf Seems similar enough.... |
Beta Was this translation helpful? Give feedback.
-
This is BIG FUCKING NEWS because it gives us our first insight into the nature of the infamous WEX Luther and his first scheme since breaking out of xMegatraz, where he had been imprisoned along with the rest of the xmega rabble, as well as his new right-hand peripheral, TCE0 - and on TCF0, which some suspect of links to WEX and his cronies!
Shows what the CCL will have access to
These don't look weird for some new timers right?
First sign that we're not in kansas anymore... CLKCTRL
Where the flying fuck did that come from? PLL MULFAC = 16x?!
It looks like the PLL can by (input freq)/(1, 2, 4, or 6) * (8 or 16).
Presumably there is an upper limit to the PLL that is much lower than these possibilities imply. I'm sure we can't run the PLL on these parts at 16 times 20 = 320 MHz :-P
New fuses. Looks like if you write 0xB4 to fuse 12 and 0x52 to fuse 11 it will disable UPDI in order to make life that much more difficult for someone trying to repurpose the chip or unbrick it. and otherwise fuse 12 should be 0 and fuse 11 should be 0x03.
Unsurprising additions.
Looks like WEX had to buy TCB's loyalty? but unless there's considerably more to this, TCB sold out pretty cheaply.
Beta Was this translation helpful? Give feedback.
All reactions