41 #define IOPORT_CREATE_PIN(port, pin) ((IOPORT_ ## port) * 32 + (pin)) 42 #define IOPORT_BASE_ADDRESS (uintptr_t)PIOA 43 #define IOPORT_PIO_OFFSET ((uintptr_t)PIOB - (uintptr_t)PIOA) 63 #define IOPORT_MODE_MUX_MASK (0x7 << 0) 64 #define IOPORT_MODE_MUX_BIT0 ( 1 << 0) 66 #if SAM3N || SAM3S || SAM4S || SAM4E || SAM4N || SAM4C || SAM4CM || SAMG || SAM4CP || SAMV71 || SAMV70 || SAME70 || SAMS70 67 #define IOPORT_MODE_MUX_BIT1 ( 1 << 1) 70 #define IOPORT_MODE_MUX_A ( 0 << 0) 71 #define IOPORT_MODE_MUX_B ( 1 << 0) 73 #if SAM3N || SAM3S || SAM4S || SAM4E || SAM4N || SAM4C || SAM4CM || SAMG || SAM4CP || SAMV71 || SAMV70 || SAME70 || SAMS70 74 #define IOPORT_MODE_MUX_C ( 2 << 0) 75 #define IOPORT_MODE_MUX_D ( 3 << 0) 78 #define IOPORT_MODE_PULLUP ( 1 << 3) 80 #if SAM3N || SAM3S || SAM4S || SAM4E || SAM4N || SAM4C || SAM4CM || SAMG || SAM4CP || SAMV71 || SAMV70 || SAME70 || SAMS70 81 #define IOPORT_MODE_PULLDOWN ( 1 << 4) 84 #define IOPORT_MODE_OPEN_DRAIN ( 1 << 5) 86 #define IOPORT_MODE_GLITCH_FILTER ( 1 << 6) 87 #define IOPORT_MODE_DEBOUNCE ( 1 << 7) 92 typedef uint32_t ioport_mode_t; 104 #if (SAM4C || SAM4CM || SAM4CP) 128 return 1U << (pin & 0x1F);
188 #if defined(IOPORT_MODE_PULLDOWN) 189 if (mode & IOPORT_MODE_PULLDOWN) {
210 base->PIO_DIFSR = mask;
216 base->PIO_SCIFSR = mask;
222 #if !defined(IOPORT_MODE_MUX_BIT1) 224 base->PIO_ABSR |= mask;
226 base->PIO_ABSR &= ~mask;
229 if (mode & IOPORT_MODE_MUX_BIT0) {
235 if (mode & IOPORT_MODE_MUX_BIT1) {
343 case IOPORT_SENSE_LEVEL_LOW:
347 case IOPORT_SENSE_LEVEL_HIGH:
static __always_inline Pio * arch_ioport_pin_to_base(ioport_pin_t pin)
__O uint32_t PIO_PER
(Pio Offset: 0x0000) PIO Enable Register
static __always_inline Pio * arch_ioport_port_to_base(ioport_port_t port)
static __always_inline void arch_ioport_toggle_pin_level(ioport_pin_t pin)
__O uint32_t PIO_MDER
(Pio Offset: 0x0050) Multi-driver Enable Register
#define IOPORT_PIO_OFFSET
__O uint32_t PIO_IFDR
(Pio Offset: 0x0024) Glitch Input Filter Disable Register
static __always_inline ioport_port_mask_t arch_ioport_pin_to_mask(ioport_pin_t pin)
static __always_inline void arch_ioport_set_port_dir(ioport_port_t port, ioport_port_mask_t mask, enum ioport_direction group_direction)
__O uint32_t PIO_PUER
(Pio Offset: 0x0064) Pull-up Enable Register
static __always_inline void arch_ioport_disable_pin(ioport_pin_t pin)
ioport_direction
IOPORT pin directions.
static __always_inline void arch_ioport_set_pin_level(ioport_pin_t pin, bool level)
static __always_inline ioport_port_t arch_ioport_pin_to_port_id(ioport_pin_t pin)
__O uint32_t PIO_PDR
(Pio Offset: 0x0004) PIO Disable Register
static __always_inline void arch_ioport_set_pin_dir(ioport_pin_t pin, enum ioport_direction dir)
#define ID_PIOB
Parallel I/O Controller B (PIOB)
#define IOPORT_MODE_PULLUP
uint32_t ioport_port_mask_t
static __always_inline void arch_ioport_enable_port(ioport_port_t port, ioport_port_mask_t mask)
__O uint32_t PIO_REHLSR
(Pio Offset: 0x00D4) Rising Edge/High-Level Select Register
static __always_inline bool arch_ioport_get_pin_level(ioport_pin_t pin)
#define IOPORT_MODE_MUX_BIT0
__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
__O uint32_t PIO_AIMDR
(Pio Offset: 0x00B4) Additional Interrupt Modes Disable Register
static __always_inline void arch_ioport_set_pin_sense_mode(ioport_pin_t pin, enum ioport_sense pin_sense)
static __always_inline void arch_ioport_set_port_level(ioport_port_t port, ioport_port_mask_t mask, enum ioport_value level)
#define IOPORT_MODE_GLITCH_FILTER
__O uint32_t PIO_MDDR
(Pio Offset: 0x0054) Multi-driver Disable Register
__O uint32_t PIO_CODR
(Pio Offset: 0x0034) Clear Output Data Register
ioport_value
IOPORT levels.
static __always_inline ioport_port_mask_t arch_ioport_get_port_level(ioport_port_t port, ioport_port_mask_t mask)
static __always_inline void arch_ioport_enable_pin(ioport_pin_t pin)
__O uint32_t PIO_ESR
(Pio Offset: 0x00C0) Edge Select Register
static __always_inline void arch_ioport_set_port_sense_mode(ioport_port_t port, ioport_port_mask_t mask, enum ioport_sense pin_sense)
__O uint32_t PIO_PPDER
(Pio Offset: 0x0094) Pad Pull-down Enable Register
static __always_inline void arch_ioport_init(void)
__O uint32_t PIO_OER
(Pio Offset: 0x0010) Output Enable Register
#define ID_PIOA
Parallel I/O Controller A (PIOA)
#define IOPORT_MODE_OPEN_DRAIN
__O uint32_t PIO_ODR
(Pio Offset: 0x0014) Output Disable Register
__O uint32_t PIO_SODR
(Pio Offset: 0x0030) Set Output Data Register
static __always_inline void arch_ioport_set_port_mode(ioport_port_t port, ioport_port_mask_t mask, ioport_mode_t mode)
__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
__O uint32_t PIO_IFSCDR
(Pio Offset: 0x0080) Input Filter Slow Clock Disable Register
#define ID_PIOD
Parallel I/O Controller D (PIOD)
#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
static __always_inline void arch_ioport_toggle_port_level(ioport_port_t port, ioport_port_mask_t mask)
static __always_inline void arch_ioport_disable_port(ioport_port_t port, ioport_port_mask_t mask)
__O uint32_t PIO_IFER
(Pio Offset: 0x0020) Glitch Input Filter Enable Register
static __always_inline void arch_ioport_set_pin_mode(ioport_pin_t pin, ioport_mode_t mode)
__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
static void sysclk_enable_peripheral_clock(uint32_t ul_id)
Enable a peripheral's clock.
__O uint32_t PIO_PUDR
(Pio Offset: 0x0060) Pull-up Disable Register
#define IOPORT_MODE_DEBOUNCE
#define ID_PIOC
Parallel I/O Controller C (PIOC)
#define PIOC
(PIOC ) Base Address
#define IOPORT_BASE_ADDRESS