39 #ifndef PIO_WPMR_WPKEY_PASSWD 40 # define PIO_WPMR_WPKEY_PASSWD PIO_WPMR_WPKEY(0x50494Fu) 56 #ifndef FREQ_SLOW_CLOCK_EXT 58 #define FREQ_SLOW_CLOCK_EXT 32768 70 const uint32_t ul_pull_up_enable)
73 if (ul_pull_up_enable) {
88 const uint32_t ul_cut_off)
90 #if (SAM3S || SAM3N || SAM4S || SAM4E || SAM4N || SAM4C || SAMG || SAM4CP || SAM4CM || SAMV71 || SAMV70 || SAME70 || SAMS70) 93 #elif (SAM3XA || SAM3U) 95 p_pio->PIO_DIFSR = ul_mask;
97 #error "Unsupported device" 106 (2 * (ul_cut_off))) - 1);
149 const uint32_t ul_mask)
159 if ((ul_reg & ul_mask) == 0) {
175 const uint32_t ul_mask)
182 #if (SAM3S || SAM3N || SAM4S || SAM4E || SAM4N || SAM4C || SAMG || SAM4CP || SAM4CM || SAMV71 || SAMV70 || SAME70 || SAMS70) 221 #elif (SAM3XA|| SAM3U) 224 ul_sr = p_pio->PIO_ABSR;
225 p_pio->PIO_ABSR &= (~ul_mask & ul_sr);
229 ul_sr = p_pio->PIO_ABSR;
230 p_pio->PIO_ABSR = (ul_mask | ul_sr);
241 #error "Unsupported device" 258 const uint32_t ul_attribute)
270 #if (SAM3S || SAM3N || SAM4S || SAM4E || SAM4N || SAM4C || SAMG || SAM4CP || SAM4CM || SAMV71 || SAMV70 || SAME70 || SAMS70) 279 #elif (SAM3XA|| SAM3U) 281 if (ul_attribute & PIO_DEGLITCH) {
282 p_pio->PIO_SCIFSR = ul_mask;
285 p_pio->PIO_DIFSR = ul_mask;
289 #error "Unsupported device" 311 const uint32_t ul_default_level,
312 const uint32_t ul_multidrive_enable,
313 const uint32_t ul_pull_up_enable)
319 if (ul_multidrive_enable) {
326 if (ul_default_level) {
349 const uint32_t ul_mask,
const uint32_t ul_attribute)
355 #if (SAM3S || SAM3N || SAM4S || SAM4E || SAM4N || SAM4C || SAM4CP || SAM4CM || SAMV71 || SAMV70 || SAME70 || SAMS70) 371 (ul_attribute & PIO_PULLUP) ? 1 : 0);
393 const uint32_t ul_mask)
395 if ((p_pio->
PIO_ODSR & ul_mask) == 0) {
411 const uint32_t ul_multi_driver_enable)
414 if (ul_multi_driver_enable) {
434 #if (SAM3S || SAM3N || SAM4S || SAM4E || SAM4N || SAM4C || SAMG || SAM4CP || SAM4CM || SAMV71 || SAMV70 || SAME70 || SAMS70) 443 void pio_pull_down(
Pio *p_pio,
const uint32_t ul_mask,
444 const uint32_t ul_pull_down_enable)
447 if (ul_pull_down_enable) {
502 #if (SAM3S || SAM3N || SAM4S || SAM4E || SAM4N || SAM4C || SAMG || SAM4CP || SAM4CM || SAMV71 || SAMV70 || SAME70 || SAMS70) 511 void pio_set_schmitt_trigger(
Pio *p_pio,
const uint32_t ul_mask)
523 uint32_t pio_get_schmitt_trigger(
const Pio *p_pio)
539 const uint32_t ul_attr)
626 const uint32_t ul_mask,
const uint32_t ul_attribute)
657 #ifndef PIO_WPMR_WPKEY_PASSWD 658 #define PIO_WPMR_WPKEY_PASSWD PIO_WPMR_WPKEY(0x50494FU) 701 return (p_pio->
PIO_PDSR >> (ul_pin & 0x1F)) & 1;
716 p_pio->
PIO_SODR = 1 << (ul_pin & 0x1F);
731 p_pio->
PIO_CODR = 1 << (ul_pin & 0x1F);
745 if (p_pio->
PIO_ODSR & (1 << (ul_pin & 0x1F))) {
747 p_pio->
PIO_CODR = 1 << (ul_pin & 0x1F);
750 p_pio->
PIO_SODR = 1 << (ul_pin & 0x1F);
777 (ul_flags & PIO_PULLUP));
779 #if (SAM3S || SAM3N || SAM4S || SAM4E || SAM4N || SAM4C || SAM4CP || SAM4CM || SAMV71 || SAMV70 || SAME70 || SAMS70) 783 (ul_flags & PIO_PULLUP));
788 (ul_flags & PIO_PULLUP));
800 == PIO_TYPE_PIO_OUTPUT_1) ? 1 : 0,
802 (ul_flags & PIO_PULLUP) ? 1 : 0);
864 uint32_t ul_mask,
const uint32_t ul_flags)
874 pio_pull_up(p_pio, ul_mask, (ul_flags & PIO_PULLUP));
876 #if (SAM3S || SAM3N || SAM4S || SAM4E || SAM4N || SAM4C || SAM4CP || SAM4CM || SAMV71 || SAMV70 || SAME70 || SAMS70) 879 pio_pull_up(p_pio, ul_mask, (ul_flags & PIO_PULLUP));
883 pio_pull_up(p_pio, ul_mask, (ul_flags & PIO_PULLUP));
895 == PIO_TYPE_PIO_OUTPUT_1) ? 1 : 0,
897 (ul_flags & PIO_PULLUP) ? 1 : 0);
918 p_pio->
PIO_IER = 1 << (ul_pin & 0x1F);
933 p_pio->
PIO_IDR = 1 << (ul_pin & 0x1F);
948 #if (SAM4C || SAM4CP) 952 }
else if (ul_pin > PIO_PB31_IDX) {
954 if (ul_pin > PIO_PB31_IDX) {
961 if (ul_pin > PIO_PB21_IDX) {
983 #if (SAM4C || SAM4CP) 987 }
else if (ul_pin > PIO_PB31_IDX) {
989 if (ul_pin > PIO_PB31_IDX) {
993 ul_id =
ID_PIOA + (ul_pin >> 5);
996 if (ul_pin > PIO_PB21_IDX) {
999 ul_id =
ID_PIOA + (ul_pin >> 5);
1001 #elif (SAMV70 || SAMV71 || SAME70 || SAMS70) 1002 ul_id =
ID_PIOA + (ul_pin >> 5);
1012 ul_id =
ID_PIOA + (ul_pin >> 5);
1027 uint32_t ul_mask = 1 << (ul_pin & 0x1F);
1031 #if (SAM3S || SAM4S || SAM4E || SAMV71 || SAMV70 || SAME70 || SAMS70) 1033 uint32_t pio_capture_enable_flag;
1042 void pio_capture_set_mode(
Pio *p_pio, uint32_t ul_mode)
1053 void pio_capture_enable(
Pio *p_pio)
1056 pio_capture_enable_flag =
true;
1064 void pio_capture_disable(
Pio *p_pio)
1067 pio_capture_enable_flag =
false;
1080 uint32_t pio_capture_read(
const Pio *p_pio, uint32_t *pul_data)
1100 void pio_capture_enable_interrupt(
Pio *p_pio,
const uint32_t ul_mask)
1112 void pio_capture_disable_interrupt(
Pio *p_pio,
const uint32_t ul_mask)
1124 uint32_t pio_capture_get_interrupt_status(
const Pio *p_pio)
1136 uint32_t pio_capture_get_interrupt_mask(
const Pio *p_pio)
1140 #if !(SAMV71 || SAMV70 || SAME70 || SAMS70) 1148 Pdc *pio_capture_get_pdc_base(
const Pio *p_pio)
1156 #if (SAM4C || SAM4CP || SAM4CM || SAMG55 || SAMV71 || SAMV70 || SAME70 || SAMS70) 1164 void pio_set_io_drive(
Pio *p_pio, uint32_t ul_line,
1165 enum pio_io_drive_mode mode)
void pio_configure_interrupt(Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_attr)
Configure the given interrupt source. Interrupt can be configured to trigger on rising edge...
__O uint32_t PIO_IER
(Pio Offset: 0x0040) Interrupt Enable Register
#define PIO_TYPE_PIO_OUTPUT_0
#define PIOA
(PIOA ) Base Address
#define UNUSED(v)
Marking v as a unused parameter or value.
__O uint32_t PIO_PER
(Pio Offset: 0x0000) PIO Enable Register
void pio_set_pin_high(uint32_t ul_pin)
Drive a GPIO pin to 1.
void pio_set_input(Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_attribute)
Configure one or more pin(s) or a PIO controller as inputs. Optionally, the corresponding internal pu...
#define PIO_TYPE_PIO_PERIPH_D
void pio_set_debounce_filter(Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_cut_off)
Configure Glitch or Debouncing filter for the specified input(s).
__O uint32_t PIO_MDER
(Pio Offset: 0x0050) Multi-driver Enable Register
__O uint32_t PIO_IFDR
(Pio Offset: 0x0024) Glitch Input Filter Disable Register
void pio_enable_pin_interrupt(uint32_t ul_pin)
Enable interrupt for a GPIO pin.
#define PIO_TYPE_PIO_PERIPH_C
uint32_t pio_get_pin_value(uint32_t ul_pin)
Return the value of a pin.
void pio_set_multi_driver(Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_multi_driver_enable)
Configure PIO pin multi-driver.
void pio_set_writeprotect(Pio *p_pio, const uint32_t ul_enable)
Enable or disable write protect of PIO registers.
void pio_set_pin_group_low(Pio *p_pio, uint32_t ul_mask)
Drive a GPIO port to 0.
__I uint32_t PIO_PCISR
(Pio Offset: 0x0160) Parallel Capture Interrupt Status Register
__O uint32_t PIO_PUER
(Pio Offset: 0x0064) Pull-up Enable Register
__I uint32_t PIO_IMR
(Pio Offset: 0x0048) Interrupt Mask Register
#define PIO_TYPE_PIO_PERIPH_B
void pio_set(Pio *p_pio, const uint32_t ul_mask)
Set a high output level on all the PIOs defined in ul_mask. This has no immediate effects on PIOs tha...
uint32_t pio_get_output_write_status(const Pio *p_pio)
Read PIO output write status.
void pio_disable_output_write(Pio *p_pio, const uint32_t ul_mask)
Disable PIO output write.
__O uint32_t PIO_IDR
(Pio Offset: 0x0044) Interrupt Disable Register
__O uint32_t PIO_PDR
(Pio Offset: 0x0004) PIO Disable Register
__IO uint32_t PIO_DRIVER
(Pio Offset: 0x0118) I/O Drive Register
__IO uint32_t PIO_SCDR
(Pio Offset: 0x008C) Slow Clock Divider Debouncing Register
__O uint32_t PIO_REHLSR
(Pio Offset: 0x00D4) Rising Edge/High-Level Select Register
void pio_set_pin_group_high(Pio *p_pio, uint32_t ul_mask)
Drive a GPIO port to 1.
__O uint32_t PIO_PPDDR
(Pio Offset: 0x0090) Pad Pull-down Disable Register
__O uint32_t PIO_AIMER
(Pio Offset: 0x00B0) Additional Interrupt Modes Enable Register
#define FREQ_SLOW_CLOCK_EXT
__O uint32_t PIO_AIMDR
(Pio Offset: 0x00B4) Additional Interrupt Modes Disable Register
__O uint32_t PIO_PCIER
(Pio Offset: 0x0154) Parallel Capture Interrupt Enable Register
__I uint32_t PIO_PCRHR
(Pio Offset: 0x0164) Parallel Capture Reception Holding Register
void pio_enable_output_write(Pio *p_pio, const uint32_t ul_mask)
Enable PIO output write for synchronous data output.
enum _pio_type pio_type_t
Parallel Input/Output (PIO) Controller driver for SAM.
uint32_t pio_get_pin_group_id(uint32_t ul_pin)
Return GPIO port peripheral ID for a GPIO pin.
__O uint32_t PIO_MDDR
(Pio Offset: 0x0054) Multi-driver Disable Register
uint32_t pio_configure_pin_group(Pio *p_pio, uint32_t ul_mask, const uint32_t ul_flags)
Perform complete pin(s) configuration; general attributes and PIO init if necessary.
__O uint32_t PIO_CODR
(Pio Offset: 0x0034) Clear Output Data Register
uint32_t pio_get_output_data_status(const Pio *p_pio, const uint32_t ul_mask)
Return 1 if one or more PIOs of the given Pin are configured to output a high level (even if they are...
#define PIO_WPMR_WPKEY_PASSWD
void pio_sync_output_write(Pio *p_pio, const uint32_t ul_mask)
Synchronously write on output pins.
void pio_set_output(Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_default_level, const uint32_t ul_multidrive_enable, const uint32_t ul_pull_up_enable)
Configure one or more pin(s) of a PIO controller as outputs, with the given default value...
void pio_enable_interrupt(Pio *p_pio, const uint32_t ul_mask)
Enable the given interrupt source. The PIO must be configured as an NVIC interrupt source as well...
__I uint32_t PIO_PCIMR
(Pio Offset: 0x015C) Parallel Capture Interrupt Mask Register
#define PIO_TYPE_PIO_PERIPH_A
__O uint32_t PIO_PCIDR
(Pio Offset: 0x0158) Parallel Capture Interrupt Disable Register
void pio_disable_interrupt(Pio *p_pio, const uint32_t ul_mask)
Disable a given interrupt source, with no added side effects.
__IO uint32_t PIO_SCHMITT
(Pio Offset: 0x0100) Schmitt Trigger Register
__O uint32_t PIO_ESR
(Pio Offset: 0x00C0) Edge Select Register
#define PIO_SCDR_DIV(value)
__O uint32_t PIO_PPDER
(Pio Offset: 0x0094) Pad Pull-down Enable Register
__I uint32_t PIO_WPSR
(Pio Offset: 0x00E8) Write Protection Status Register
__O uint32_t PIO_OER
(Pio Offset: 0x0010) Output Enable Register
__I uint32_t PIO_OWSR
(Pio Offset: 0x00A8) Output Write Status Register
#define PIO_PCMR_PCEN
(PIO_PCMR) Parallel Capture Mode Enable
#define ID_PIOA
Parallel I/O Controller A (PIOA)
void pio_toggle_pin(uint32_t ul_pin)
Toggle a GPIO pin.
__O uint32_t PIO_ODR
(Pio Offset: 0x0014) Output Disable Register
void pio_toggle_pin_group(Pio *p_pio, uint32_t ul_mask)
Toggle a GPIO group.
__O uint32_t PIO_SODR
(Pio Offset: 0x0030) Set Output Data Register
__IO uint32_t PIO_PCMR
(Pio Offset: 0x0150) Parallel Capture Mode Register
__I uint32_t PIO_PDSR
(Pio Offset: 0x003C) Pin Data Status Register
#define PIOD
(PIOD ) Base Address
__IO uint32_t PIO_ABCDSR[2]
(Pio Offset: 0x0070) Peripheral Select Register
void pio_pull_up(Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_pull_up_enable)
Configure PIO internal pull-up.
Pio * pio_get_pin_group(uint32_t ul_pin)
Return GPIO port for a GPIO pin.
__O uint32_t PIO_IFSCDR
(Pio Offset: 0x0080) Input Filter Slow Clock Disable Register
uint32_t pio_get_interrupt_status(const Pio *p_pio)
Read and clear PIO interrupt status.
void pio_set_pin_low(uint32_t ul_pin)
Drive a GPIO pin to 0.
#define PIO_WPMR_WPEN
(PIO_WPMR) Write Protection Enable
#define ID_PIOD
Parallel I/O Controller D (PIOD)
__O uint32_t PIO_OWDR
(Pio Offset: 0x00A4) Output Write Disable
#define ID_PIOE
Parallel I/O Controller E (PIOE)
__O uint32_t PIO_OWER
(Pio Offset: 0x00A0) Output Write Enable
__O uint32_t PIO_IFSCER
(Pio Offset: 0x0084) Input Filter Slow Clock Enable Register
__IO uint32_t PIO_ODSR
(Pio Offset: 0x0038) Output Data Status Register
__O uint32_t PIO_IFER
(Pio Offset: 0x0020) Glitch Input Filter Enable Register
uint32_t pio_get(Pio *p_pio, const pio_type_t ul_type, const uint32_t ul_mask)
Return 1 if one or more PIOs of the given Pin instance currently have a high level; otherwise returns...
__IO uint32_t PIO_WPMR
(Pio Offset: 0x00E4) Write Protection Mode Register
uint32_t pio_get_multi_driver_status(const Pio *p_pio)
Get multi-driver status.
#define PIO_TYPE_PIO_INPUT
uint32_t pio_configure(Pio *p_pio, const pio_type_t ul_type, const uint32_t ul_mask, const uint32_t ul_attribute)
Perform complete pin(s) configuration; general attributes and PIO init if necessary.
__O uint32_t PIO_FELLSR
(Pio Offset: 0x00D0) Falling Edge/Low-Level Select Register
__O uint32_t PIO_LSR
(Pio Offset: 0x00C4) Level Select Register
uint32_t pio_configure_pin(uint32_t ul_pin, const uint32_t ul_flags)
Perform complete pin(s) configuration; general attributes and PIO init if necessary.
void pio_disable_pin_interrupt(uint32_t ul_pin)
Disable interrupt for a GPIO pin.
void pio_clear(Pio *p_pio, const uint32_t ul_mask)
Set a low output level on all the PIOs defined in ul_mask. This has no immediate effects on PIOs that...
__O uint32_t PIO_PUDR
(Pio Offset: 0x0060) Pull-up Disable Register
__I uint32_t PIO_ISR
(Pio Offset: 0x004C) Interrupt Status Register
uint32_t pio_get_writeprotect_status(const Pio *p_pio)
Read write protect status.
#define ID_PIOC
Parallel I/O Controller C (PIOC)
#define PIOC
(PIOC ) Base Address
uint32_t pio_get_interrupt_mask(const Pio *p_pio)
Read PIO interrupt mask.
void pio_set_additional_interrupt_mode(Pio *p_pio, const uint32_t ul_mask, const uint32_t ul_attribute)
Set additional interrupt mode.
#define PIO_PCISR_DRDY
(PIO_PCISR) Parallel Capture Mode Data Ready
uint32_t pio_get_pin_group_mask(uint32_t ul_pin)
Return GPIO port pin mask for a GPIO pin.
#define PIO_TYPE_PIO_OUTPUT_1
void pio_set_peripheral(Pio *p_pio, const pio_type_t ul_type, const uint32_t ul_mask)
Configure IO of a PIO controller as being controlled by a specific peripheral.
__I uint32_t PIO_MDSR
(Pio Offset: 0x0058) Multi-driver Status Register