afec.c
Go to the documentation of this file.
1 
33 /*
34  * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
35  */
36 
37 #include "afec.h"
38 #include "sleepmgr.h"
39 #include "status_codes.h"
40 #include "sysclk.h"
41 #include "pmc.h"
42 
53 #if defined(AFEC1)
54 #define NUM_OF_AFEC (2UL)
55 #else
56 #define NUM_OF_AFEC (1UL)
57 #endif
58 
59 /* The gap between bit EOC15 and DRDY in interrupt register */
60 #if defined __SAM4E8C__ || defined __SAM4E16C__ || defined __SAM4E8CB__ || defined __SAM4E16CB__
61 #define AFEC_INTERRUPT_GAP1 (17UL)
62 #elif defined __SAM4E8E__ || defined __SAM4E16E__
63 #define AFEC_INTERRUPT_GAP1 (8UL)
64 #elif (SAMV71 || SAMV70 || SAME70 || SAMS70)
65 /* The gap between bit EOC11 and DRDY in interrupt register */
66 #define AFEC_INTERRUPT_GAP1 (12UL)
67 #endif
68 
69 #if (SAMV71 || SAMV70 || SAME70 || SAMS70)
70 /* The gap between bit COMPE and TEMPCHG in interrupt register */
71 #define AFEC_INTERRUPT_GAP2 (3UL)
72 #else
73 /* The gap between bit RXBUFF and TEMPCHG in interrupt register */
74 #define AFEC_INTERRUPT_GAP2 (1UL)
75 #endif
76 
77 /* The number of channel in channel sequence1 register */
78 #define AFEC_SEQ1_CHANNEL_NUM (8UL)
79 
80 #if (SAMV71 || SAMV70 || SAME70 || SAMS70)
81 /* The interrupt source number of temperature sensor */
82 #define AFEC_TEMP_INT_SOURCE_NUM (11UL)
83 #else
84 /* The interrupt source number of temperature sensor */
85 #define AFEC_TEMP_INT_SOURCE_NUM (15UL)
86 #endif
87 
88 afec_callback_t afec_callback_pointer[NUM_OF_AFEC][_AFEC_NUM_OF_INTERRUPT_SOURCE];
89 
90 
99 static uint32_t afec_find_inst_num(Afec *const afec)
100 {
101 #if defined(AFEC1)
102  if (afec == AFEC1) {
103  return 1;
104  }
105 #endif
106 #if defined(AFEC0)
107  if (afec == AFEC0) {
108  return 0;
109  }
110 #endif
111  return 0;
112 }
113 
122 static uint32_t afec_find_pid(Afec *const afec)
123 {
124 #if defined(ID_AFEC1)
125  if (afec == AFEC1) {
126  return ID_AFEC1;
127  }
128 #endif
129 #if defined(ID_AFEC0)
130  if (afec == AFEC0) {
131  return ID_AFEC0;
132  }
133 #endif
134  return ID_AFEC0;
135 }
136 
144 static void afec_set_config(Afec *const afec, struct afec_config *config)
145 {
146  uint32_t reg = 0;
147 
148  reg = (config->useq ? AFEC_MR_USEQ_REG_ORDER : 0) |
149  #if (SAMV71 || SAMV70 || SAME70 || SAMS70)
150  AFEC_MR_PRESCAL((config->mck / config->afec_clock )- 1) |
151  AFEC_MR_ONE |
152  #else
153  (config->anach ? AFEC_MR_ANACH_ALLOWED : 0) |
154  AFEC_MR_PRESCAL(config->mck / (2 * config->afec_clock) - 1) |
155  (config->settling_time) |
156  #endif
157  AFEC_MR_TRACKTIM(config->tracktim) |
158  AFEC_MR_TRANSFER(config->transfer) |
159  (config->startup_time);
160 
161  afec->AFEC_MR = reg;
162 
163  afec->AFEC_EMR = (config->tag ? AFEC_EMR_TAG : 0) |
164  (config->resolution) |
165  (config->stm ? AFEC_EMR_STM : 0);
166  #if (SAMV71 || SAMV70 || SAME70 || SAMS70)
168  #else
169  afec->AFEC_ACR = AFEC_ACR_IBCTL(config->ibctl);
170  #endif
171 }
172 
180 void afec_ch_set_config(Afec *const afec, const enum afec_channel_num channel,
181  struct afec_ch_config *config)
182 {
183  afec_ch_sanity_check(afec, channel);
184  uint32_t reg = 0;
185 
186  reg = afec->AFEC_DIFFR;
187  reg &= ~(0x1u << channel);
188  reg |= (config->diff) ? (0x1u << channel) : 0;
189  afec->AFEC_DIFFR = reg;
190 
191  reg = afec->AFEC_CGR;
192  reg &= ~(0x03u << (2 * channel));
193  reg |= (config->gain) << (2 * channel);
194  afec->AFEC_CGR = reg;
195 }
196 
205 {
206  Assert(afec == AFEC0);
207 
208  uint32_t reg = 0;
209 
210  reg = ((config->rctc) ? AFEC_TEMPMR_RTCT : 0) | (config->mode);
211  afec->AFEC_TEMPMR = reg;
212 
215 
216 }
217 
239 void afec_get_config_defaults(struct afec_config *const cfg)
240 {
241  /* Sanity check argument. */
242  Assert(cfg);
243 
244  cfg->resolution = AFEC_12_BITS;
245  cfg->mck = sysclk_get_cpu_hz();
246  cfg->afec_clock = 6000000UL;
248  #if !(SAMV71 || SAMV70 || SAME70 || SAMS70)
249  cfg->settling_time = AFEC_SETTLING_TIME_0;
250  #endif
251  cfg->tracktim = 2;
252  cfg->transfer = 1;
253  cfg->anach = true;
254  cfg->useq = false;
255  cfg->tag = true;
256  cfg->stm = true;
257  cfg->ibctl = 1;
258 }
259 
272 {
273  /*Sanity check argument. */
274  Assert(cfg);
275 
276  cfg->diff = false;
277  cfg->gain = AFEC_GAINVALUE_1;
278 
279 }
280 
295  struct afec_temp_sensor_config *const cfg)
296 {
297  /*Sanity check argument. */
298  Assert(cfg);
299 
300  cfg->rctc = false;
302  cfg->low_threshold= 0xFF;
303  cfg->high_threshold= 0xFFF;
304 }
305 
315 enum status_code afec_init(Afec *const afec, struct afec_config *config)
316 {
317  Assert(afec);
318  Assert(config);
319 
320  if ((afec_get_interrupt_status(afec) & AFEC_ISR_DRDY) == AFEC_ISR_DRDY) {
321  return STATUS_ERR_BUSY;
322  }
323 
324  /* Reset and configure the AFEC module */
325  afec->AFEC_CR = AFEC_CR_SWRST;
326  afec_set_config(afec, config);
327 
328  uint32_t i;
329  if(afec == AFEC0) {
330  for (i = 0; i < _AFEC_NUM_OF_INTERRUPT_SOURCE; i++){
331  afec_callback_pointer[0][i] = 0;
332  }
333  }
334  if(afec == AFEC1) {
335  for (i = 0; i < _AFEC_NUM_OF_INTERRUPT_SOURCE; i++){
336  afec_callback_pointer[1][i] = 0;
337  }
338  }
339 
340  return STATUS_OK;
341 }
342 
352  const enum afec_cmp_mode mode,
353  const enum afec_channel_num channel, uint8_t cmp_filter)
354 {
355  if (channel != AFEC_CHANNEL_ALL) {
356  afec_ch_sanity_check(afec, channel);
357  }
358 
359  uint32_t reg;
360 
361  reg = afec->AFEC_EMR;
362 
363  reg &= ~(AFEC_EMR_CMPSEL_Msk |
366  reg |= mode |
367  ((channel == AFEC_CHANNEL_ALL) ? AFEC_EMR_CMPALL
368  : AFEC_EMR_CMPSEL(channel)) |
369  AFEC_EMR_CMPFILTER(cmp_filter);
370 
371  afec->AFEC_EMR = reg;
372 }
373 
380 void afec_set_power_mode(Afec *const afec,
381  const enum afec_power_mode mode)
382 {
383  uint32_t reg;
384 
385  reg = afec->AFEC_MR;
386 
387  switch(mode) {
388  case AFEC_POWER_MODE_0:
390  break;
391  case AFEC_POWER_MODE_1:
392  reg |= AFEC_MR_FWUP_ON;
393  break;
394  case AFEC_POWER_MODE_2:
395  reg |= AFEC_MR_SLEEP_SLEEP;
396  reg &= ~AFEC_MR_FWUP_ON;
397  break;
398  }
399 
400  afec->AFEC_MR = reg;
401 }
402 
411 void afec_set_callback(Afec *const afec, enum afec_interrupt_source source,
412  afec_callback_t callback, uint8_t irq_level)
413 {
414  Assert(afec);
415  Assert(callback);
416 
417  uint32_t i = afec_find_inst_num(afec);
418  afec_callback_pointer[i][source] = callback;
419  if (!i) {
420  irq_register_handler(AFEC0_IRQn, irq_level);
421  } else if (i == 1) {
422  irq_register_handler(AFEC1_IRQn, irq_level);
423  }
424  /* Enable the specified interrupt source */
425  afec_enable_interrupt(afec, source);
426 }
427 
434 void afec_enable_interrupt(Afec *const afec,
435  enum afec_interrupt_source interrupt_source)
436 {
437  if (interrupt_source == AFEC_INTERRUPT_ALL) {
438  afec->AFEC_IER = AFEC_INTERRUPT_ALL;
439  return;
440  }
441 
442  if (interrupt_source < AFEC_INTERRUPT_DATA_READY) {
443  #if (SAMV71 || SAMV70 || SAME70 || SAMS70)
444  if (interrupt_source == AFEC_INTERRUPT_EOC_11) {
445  afec->AFEC_IER = 1 << AFEC_TEMP_INT_SOURCE_NUM;
446  #else
447  if (interrupt_source == AFEC_INTERRUPT_EOC_15) {
448  afec->AFEC_IER = 1 << AFEC_TEMP_INT_SOURCE_NUM;
449  #endif
450  } else {
451  afec->AFEC_IER = 1 << interrupt_source;
452  }
453  } else if (interrupt_source < AFEC_INTERRUPT_TEMP_CHANGE) {
454  afec->AFEC_IER = 1 << (interrupt_source + AFEC_INTERRUPT_GAP1);
455  } else {
456  afec->AFEC_IER = 1 << (interrupt_source + AFEC_INTERRUPT_GAP1
458  }
459 }
460 
467 void afec_disable_interrupt(Afec *const afec,
468  enum afec_interrupt_source interrupt_source)
469 {
470  if (interrupt_source == AFEC_INTERRUPT_ALL) {
471  afec->AFEC_IDR = AFEC_INTERRUPT_ALL;
472  return;
473  }
474 
475  if (interrupt_source < AFEC_INTERRUPT_DATA_READY) {
476  #if (SAMV71 || SAMV70 || SAME70 || SAMS70)
477  if (interrupt_source == AFEC_INTERRUPT_EOC_11) {
478  afec->AFEC_IDR = 1 << AFEC_TEMP_INT_SOURCE_NUM;
479  #else
480  if (interrupt_source == AFEC_INTERRUPT_EOC_15) {
481  afec->AFEC_IDR = 1 << AFEC_TEMP_INT_SOURCE_NUM;
482  #endif
483  } else {
484  afec->AFEC_IDR = 1 << interrupt_source;
485  }
486  } else if (interrupt_source < AFEC_INTERRUPT_TEMP_CHANGE) {
487  afec->AFEC_IDR = 1 << (interrupt_source + AFEC_INTERRUPT_GAP1);
488  } else {
489  afec->AFEC_IDR = 1 << (interrupt_source + AFEC_INTERRUPT_GAP1
491  }
492 }
493 
504 static void afec_interrupt(uint8_t inst_num,
505  enum afec_interrupt_source source)
506 {
507  if (afec_callback_pointer[inst_num][source]) {
508  afec_callback_pointer[inst_num][source]();
509  }
510 }
511 
518 static void afec_process_callback(Afec *const afec)
519 {
520  volatile uint32_t status;
521  uint32_t cnt, inst_num;
522 
523  status = afec_get_interrupt_status(afec) & afec_get_interrupt_mask(afec);
524  inst_num = afec_find_inst_num(afec);
525 
526  for (cnt = 0; cnt < _AFEC_NUM_OF_INTERRUPT_SOURCE; cnt++) {
527  if (cnt < AFEC_INTERRUPT_DATA_READY) {
528  #if defined __SAM4E8C__ || defined __SAM4E16C__ || defined __SAM4E8CB__ || defined __SAM4E16CB__
529  if(cnt == AFEC_INTERRUPT_EOC_15) {
530  if (status & (1 << AFEC_TEMP_INT_SOURCE_NUM)) {
531  afec_interrupt(inst_num, (enum afec_interrupt_source)cnt);
532  }
533  } else {
534  if (status & (1 << cnt)) {
535  afec_interrupt(inst_num, (enum afec_interrupt_source)cnt);
536  }
537  }
538  #elif defined __SAM4E8E__ || defined __SAM4E16E__ || SAMV71 || SAMV70 || SAMS70 || SAME70
539  if (status & (1 << cnt)) {
540  afec_interrupt(inst_num, (enum afec_interrupt_source)cnt);
541  }
542  #endif
543  } else if (cnt < AFEC_INTERRUPT_TEMP_CHANGE) {
544  if (status & (1 << (cnt + AFEC_INTERRUPT_GAP1))) {
545  afec_interrupt(inst_num, (enum afec_interrupt_source)cnt);
546  }
547  } else {
548  if (status & (1 << (cnt + AFEC_INTERRUPT_GAP1 + AFEC_INTERRUPT_GAP2))) {
549  afec_interrupt(inst_num, (enum afec_interrupt_source)cnt);
550  }
551  }
552  }
553 }
554 
558 void AFEC0_Handler(void)
559 {
561 }
562 
566 void AFEC1_Handler(void)
567 {
569 }
570 
576 void afec_enable(Afec *const afec)
577 {
578  Assert(afec);
579  uint32_t pid;
580 
581  pid = afec_find_pid(afec);
582  /* Enable peripheral clock. */
585 }
586 
592 void afec_disable(Afec *const afec)
593 {
594  Assert(afec);
595  uint32_t pid;
596 
597  pid = afec_find_pid(afec);
598  /* Disable peripheral clock. */
601 }
602 
610 void afec_configure_sequence(Afec *const afec,
611  const enum afec_channel_num ch_list[], uint8_t uc_num)
612 {
613  uint8_t uc_counter;
614 
615  /* Set user sequence mode */
617  afec->AFEC_SEQ1R = 0;
618  afec->AFEC_SEQ2R = 0;
619 
620  if (uc_num < AFEC_SEQ1_CHANNEL_NUM) {
621  for (uc_counter = 0; uc_counter < uc_num; uc_counter++) {
622  afec->AFEC_SEQ1R |=
623  ch_list[uc_counter] << (4 * uc_counter);
624  }
625  } else {
626  for (uc_counter = 0; uc_counter < AFEC_SEQ1_CHANNEL_NUM; uc_counter++) {
627  afec->AFEC_SEQ1R |=
628  ch_list[uc_counter] << (4 * uc_counter);
629  }
630  for (uc_counter = 0; uc_counter < uc_num - AFEC_SEQ1_CHANNEL_NUM;
631  uc_counter++) {
632  afec->AFEC_SEQ2R |=
633  ch_list[uc_counter + AFEC_SEQ1_CHANNEL_NUM] << (4 * uc_counter);
634  }
635  }
636 }
637 
638 #if (SAMV71 || SAMV70 || SAME70 || SAMS70)
639 
647 void afec_configure_auto_error_correction(Afec *const afec,
648  const enum afec_channel_num channel, int16_t offsetcorr, uint16_t gaincorr)
649 {
650 
651 
652  if (channel != AFEC_CHANNEL_ALL) {
653  afec_ch_sanity_check(afec, channel);
654  }
655 
656  uint32_t reg = 0;
657  reg = afec->AFEC_CECR;
658  reg = (channel == AFEC_CHANNEL_ALL)? 0 : ~(0x1u << channel);
659  reg |= (channel == AFEC_CHANNEL_ALL)? AFEC_CHANNEL_ALL : (0x1u << channel);
660  afec->AFEC_CECR = reg;
661 
662  afec->AFEC_COSR = AFEC_COSR_CSEL;
663  afec->AFEC_CVR = AFEC_CVR_OFFSETCORR(offsetcorr) | AFEC_CVR_GAINCORR(gaincorr);
664 
665 }
666 
675  uint32_t afec_get_correction_value(Afec *const afec,
676  const enum afec_channel_num afec_ch)
677 {
678  uint32_t corrected_data = 0;
679  uint32_t converted_data = 0;
680 
681  afec_ch_sanity_check(afec, afec_ch);
682 
683  afec->AFEC_CSELR = afec_ch;
684  converted_data = afec->AFEC_CDR;
685 
686  corrected_data = (converted_data + (afec->AFEC_CVR & AFEC_CVR_OFFSETCORR_Msk)) *
687  (afec->AFEC_CVR >> AFEC_CVR_GAINCORR_Pos) / 1024u;
688  return corrected_data;
689 
690 }
691 
699 void afec_set_sample_hold_mode(Afec *const afec,
700  const enum afec_channel_num channel, const enum afec_sample_hold_mode mode)
701 {
702  if (channel != AFEC_CHANNEL_ALL) {
703  afec_ch_sanity_check(afec, channel);
704  }
705 
706  uint32_t reg = 0;
707  reg = afec->AFEC_SHMR;
708  if (mode == AFEC_SAMPLE_HOLD_MODE_1) {
709 
710  reg |= (channel == AFEC_CHANNEL_ALL)? AFEC_CHANNEL_ALL : 0x1u << channel;
711  }
712  else {
713 
714  reg = (channel == AFEC_CHANNEL_ALL)? 0 : ~(0x1u << channel);
715  }
716  afec->AFEC_SHMR = reg;
717 
718 }
719 #endif
720 
#define AFEC_TEMP_INT_SOURCE_NUM
Definition: afec.c:85
#define ID_AFEC0
Analog Front End 0 (AFEC0)
Definition: same70j19.h:427
void AFEC1_Handler(void)
Interrupt handler for AFEC1.
Definition: afec.c:566
void afec_set_power_mode(Afec *const afec, const enum afec_power_mode mode)
Configure AFEC power mode.
Definition: afec.c:380
#define AFEC_MR_TRACKTIM(value)
#define ID_AFEC1
Analog Front End 1 (AFEC1)
Definition: same70j19.h:435
#define AFEC_TEMPCWR_TLOWTHRES(value)
#define SAME70
Definition: parts.h:1730
static void afec_interrupt(uint8_t inst_num, enum afec_interrupt_source source)
Definition: afec.c:504
#define AFEC_ISR_DRDY
(AFEC_ISR) Data Ready (cleared by reading AFEC_LCDR)
void afec_temp_sensor_get_config_defaults(struct afec_temp_sensor_config *const cfg)
Get the AFEC Temperature Sensor default configurations.
Definition: afec.c:294
void afec_ch_get_config_defaults(struct afec_ch_config *const cfg)
Get the AFEC channel default configurations.
Definition: afec.c:271
Success.
Definition: status_codes.h:66
enum afec_resolution resolution
#define AFEC_CVR_GAINCORR(value)
Status code definitions.
#define AFEC_ACR_PGA0EN
(AFEC_ACR) PGA0 Enable
#define irq_register_handler(int_num, int_prio)
Register handler for interrupt.
static uint32_t sysclk_get_cpu_hz(void)
Return the current rate in Hz of the CPU clock.
#define AFEC_SEQ1_CHANNEL_NUM
Definition: afec.c:78
Analog-Front-End Controller configuration structure.
void afec_temp_sensor_set_config(Afec *const afec, struct afec_temp_sensor_config *config)
Configure the AFEC temperature sensor.
Definition: afec.c:203
#define AFEC_MR_USEQ_REG_ORDER
(AFEC_MR) User Sequence mode: The sequence respects what is defined in AFEC_SEQ1R and AFEC_SEQ1R...
#define AFEC1
(AFEC1 ) Base Address
Definition: same70j19.h:517
enum afec_startup_time startup_time
#define AFEC_MR_FWUP_ON
(AFEC_MR) Fast wake-up Sleep mode: The voltage reference is ON between conversions and AFE is OFF...
static uint32_t afec_find_inst_num(Afec *const afec)
Definition: afec.c:99
#define AFEC_EMR_CMPALL
(AFEC_EMR) Compare All Channels
uint32_t pmc_disable_periph_clk(uint32_t ul_id)
Disable the specified peripheral clock.
Definition: pmc.c:722
#define AFEC_EMR_STM
(AFEC_EMR) Single Trigger Mode
#define AFEC_EMR_CMPFILTER_Msk
(AFEC_EMR) Compare Event Filtering
void afec_enable(Afec *const afec)
Enable AFEC Module.
Definition: afec.c:576
__IO uint32_t AFEC_SEQ1R
(Afec Offset: 0x0C) AFEC Channel Sequence 1 Register
uint32_t pmc_enable_periph_clk(uint32_t ul_id)
Enable the specified peripheral clock.
Definition: pmc.c:682
__O uint32_t AFEC_IDR
(Afec Offset: 0x28) AFEC Interrupt Disable Register
#define AFEC_EMR_CMPSEL(value)
#define AFEC_MR_ONE
(AFEC_MR) One
uint32_t afec_clock
__IO uint32_t AFEC_TEMPCWR
(Afec Offset: 0x74) AFEC Temperature Compare Window Register
static void afec_set_config(Afec *const afec, struct afec_config *config)
Definition: afec.c:144
enum afec_gainvalue gain
status_code
Definition: status_codes.h:65
#define AFEC_CR_SWRST
(AFEC_CR) Software Reset
void afec_configure_sequence(Afec *const afec, const enum afec_channel_num ch_list[], uint8_t uc_num)
Configure conversion sequence.
Definition: afec.c:610
__IO uint32_t AFEC_EMR
(Afec Offset: 0x08) AFEC Extended Mode Register
#define AFEC_MR_TRANSFER(value)
#define AFEC_TEMPMR_RTCT
(AFEC_TEMPMR) Temperature Sensor RTC Trigger Mode
#define AFEC_INTERRUPT_GAP2
Definition: afec.c:74
__IO uint32_t AFEC_SEQ2R
(Afec Offset: 0x10) AFEC Channel Sequence 2 Register
void afec_get_config_defaults(struct afec_config *const cfg)
Get the AFEC default configurations.
Definition: afec.c:239
#define AFEC_ACR_PGA1EN
(AFEC_ACR) PGA1 Enable
void afec_disable(Afec *const afec)
Disable AFEC Module.
Definition: afec.c:592
#define AFEC_CVR_OFFSETCORR(value)
__IO uint32_t AFEC_TEMPMR
(Afec Offset: 0x70) AFEC Temperature Sensor Mode Register
#define AFEC_MR_SLEEP_SLEEP
(AFEC_MR) Sleep mode: The AFE and reference voltage circuitry are OFF between conversions.
__O uint32_t AFEC_IER
(Afec Offset: 0x24) AFEC Interrupt Enable Register
#define NUM_OF_AFEC
Definition: afec.c:56
#define SAMV70
Definition: parts.h:1726
__IO uint32_t AFEC_CGR
(Afec Offset: 0x54) AFEC Channel Gain Register
Analog-Front-End Controller driver for SAM.
static uint32_t afec_get_interrupt_status(Afec *const afec)
Get AFEC interrupt status.
enum afec_temp_cmp_mode mode
__IO uint32_t AFEC_COSR
(Afec Offset: 0xD0) AFEC Correction Select Register
#define AFEC_EMR_CMPMODE_Msk
(AFEC_EMR) Comparison Mode
#define AFEC_EMR_TAG
(AFEC_EMR) TAG of the AFEC_LDCR
void afec_enable_interrupt(Afec *const afec, enum afec_interrupt_source interrupt_source)
Enable AFEC interrupts.
Definition: afec.c:434
static uint32_t afec_find_pid(Afec *const afec)
Definition: afec.c:122
void afec_disable_interrupt(Afec *const afec, enum afec_interrupt_source interrupt_source)
Disable AFEC interrupts.
Definition: afec.c:467
__IO uint32_t AFEC_CVR
(Afec Offset: 0xD4) AFEC Correction Values Register
afec_power_mode
Afec hardware registers.
void(* afec_callback_t)(void)
void afec_set_callback(Afec *const afec, enum afec_interrupt_source source, afec_callback_t callback, uint8_t irq_level)
Set callback for AFEC.
Definition: afec.c:411
static void afec_process_callback(Afec *const afec)
Definition: afec.c:518
#define AFEC_TEMPCWR_THIGHTHRES(value)
__IO uint32_t AFEC_CECR
(Afec Offset: 0xD8) AFEC Channel Error Correction Register
#define AFEC_ACR_IBCTL(value)
#define AFEC_EMR_CMPSEL_Msk
(AFEC_EMR) Comparison Selected Channel
afec_cmp_mode
__IO uint32_t AFEC_SHMR
(Afec Offset: 0xA0) AFEC Sample & Hold Mode Register
#define SAMS70
Definition: parts.h:1734
#define AFEC0
(AFEC0 ) Base Address
Definition: same70j19.h:509
#define AFEC_MR_PRESCAL(value)
enum status_code afec_init(Afec *const afec, struct afec_config *config)
Initialize the AFEC Module.
Definition: afec.c:315
#define AFEC_COSR_CSEL
(AFEC_COSR) Sample & Hold unit Correction Select
#define AFEC_CVR_OFFSETCORR_Msk
(AFEC_CVR) Offset Correction
__IO uint32_t AFEC_DIFFR
(Afec Offset: 0x60) AFEC Channel Differential Register
static void sleepmgr_lock_mode(enum sleepmgr_mode mode)
Increase lock count for a sleep mode.
Definition: sleepmgr.h:137
static void afec_ch_sanity_check(Afec *const afec, const enum afec_channel_num channel)
void afec_set_comparison_mode(Afec *const afec, const enum afec_cmp_mode mode, const enum afec_channel_num channel, uint8_t cmp_filter)
Configure comparison mode.
Definition: afec.c:351
__IO uint32_t AFEC_MR
(Afec Offset: 0x04) AFEC Mode Register
#define Assert(expr)
This macro is used to test fatal errors.
Definition: compiler.h:196
__O uint32_t AFEC_CR
(Afec Offset: 0x00) AFEC Control Register
__IO uint32_t AFEC_CSELR
(Afec Offset: 0x64) AFEC Channel Selection Register
__IO uint32_t AFEC_ACR
(Afec Offset: 0x94) AFEC Analog Control Register
static void sleepmgr_unlock_mode(enum sleepmgr_mode mode)
Decrease lock count for a sleep mode.
Definition: sleepmgr.h:169
static uint32_t afec_get_interrupt_mask(Afec *const afec)
Get AFEC interrupt mask.
#define AFEC_EMR_CMPFILTER(value)
void AFEC0_Handler(void)
Interrupt handler for AFEC0.
Definition: afec.c:558
#define SAMV71
Definition: parts.h:1722
afec_callback_t afec_callback_pointer[NUM_OF_AFEC][_AFEC_NUM_OF_INTERRUPT_SOURCE]
Definition: afec.c:88
void afec_ch_set_config(Afec *const afec, const enum afec_channel_num channel, struct afec_ch_config *config)
Configure the AFEC channel.
Definition: afec.c:180
__I uint32_t AFEC_CDR
(Afec Offset: 0x68) AFEC Channel Data Register


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:08