#include "chip.h"
#include <stdint.h>
Go to the source code of this file.
|
uint8_t | PIO_Configure (const Pin *list, uint32_t size) |
| Configures a list of Pin instances, each of which can either hold a single pin or a group of pins, depending on the mask value; all pins are configured by this function. The size of the array must also be provided and is easily computed using PIO_LISTSIZE whenever its length is not known in advance. More...
|
|
void | PIO_Set (const Pin *pin) |
| Sets a high output level on all the PIOs defined in the given Pin instance. This has no immediate effects on PIOs that are not output, but the PIO controller will memorize the value they are changed to outputs. More...
|
|
void | PIO_Clear (const Pin *pin) |
| Sets a low output level on all the PIOs defined in the given Pin instance. This has no immediate effects on PIOs that are not output, but the PIO controller will memorize the value they are changed to outputs. More...
|
|
uint8_t | PIO_Get (const Pin *pin) |
| Returns 1 if one or more PIO of the given Pin instance currently have a high level; otherwise returns 0. This method returns the actual value that is being read on the pin. To return the supposed output value of a pin, use PIO_GetOutputDataStatus() instead. More...
|
|
uint8_t | PIO_GetOutputDataStatus (const Pin *pin) |
| Returns 1 if one or more PIO of the given Pin are configured to output a high level (even if they are not output). To get the actual value of the pin, use PIO_Get() instead. More...
|
|
void | PIO_SetDebounceFilter (const Pin *pin, uint32_t cuttoff) |
| Configures Glitch or Denouncing filter for input. More...
|
|
void | PIO_EnableWriteProtect (const Pin *pin) |
| Enable write protect. More...
|
|
void | PIO_DisableWriteProtect (const Pin *pin) |
| Disable write protect. More...
|
|
void | PIO_SetPinType (Pin *pin, uint8_t pinType) |
| Set pin type the pin is controlled by the corresponding peripheral (A, B, C, D,E) More...
|
|
uint32_t | PIO_GetWriteProtectViolationInfo (const Pin *pin) |
| Get write protect violation information. More...
|
|
void | PIO_SetDriveStrength (const Pin *pin, uint8_t strength) |
| Set the drive strength of the pin. More...
|
|
Purpose
This file provides a basic API for PIO configuration and usage of user-controlled pins. Please refer to the board.h file for a list of available pin definitions.
Usage
- Define a constant pin description array such as the following one, using the existing definitions provided by the board.h file if possible:
const Pin pPins[] = {PIN_USART0_TXD, PIN_USART0_RXD};
Alternatively, it is possible to add new pins by provided the full Pin structure:
(1 << 10) | (1 << 11),
REG_PIOA,
ID_PIOA,
};
#define PIO_INPUT
Definition: pio.h:91
#define PIO_PULLUP
Definition: pio.h:100
- Configure a pin array by calling PIO_Configure() with a pointer to the array and its size (which is computed using the PIO_LISTSIZE macro).
- Change and get the value of a user-controlled pin using the PIO_Set, PIO_Clear and PIO_Get methods.
- Get the level being currently output by a user-controlled pin configured as an output using PIO_GetOutputDataStatus().
◆ PIO_DEBOUNCE
#define PIO_DEBOUNCE (1 << 3) |
The internal debouncing filter is active.
◆ PIO_DEFAULT
#define PIO_DEFAULT (0 << 0) |
Default pin configuration (no attribute).
◆ PIO_DEGLITCH
#define PIO_DEGLITCH (1 << 1) |
The internal glitch filter is active.
◆ PIO_INPUT
◆ PIO_IT_AIME
#define PIO_IT_AIME (1 << 4) |
Enable additional interrupt modes.
◆ PIO_IT_EDGE
#define PIO_IT_EDGE (1 << 6) |
Interrupt Edge detection is active.
◆ PIO_IT_FALL_EDGE
Falling edge interrupt is active
◆ PIO_IT_HIGH_LEVEL
High level interrupt is active
◆ PIO_IT_LOW_LEVEL
Low level interrupt is active
◆ PIO_IT_RE_OR_HL
#define PIO_IT_RE_OR_HL (1 << 5) |
Interrupt High Level/Rising Edge detection is active.
◆ PIO_IT_RISE_EDGE
Rising edge interrupt is active
◆ PIO_LISTSIZE
#define PIO_LISTSIZE |
( |
|
pPins | ) |
(sizeof(pPins) / sizeof(Pin)) |
Calculates the size of an array of Pin instances. The array must be defined locally (i.e. not a pointer), otherwise the computation will not be correct.
- Parameters
-
pPins | Local array of Pin instances. |
- Returns
- Number of elements in array.
◆ PIO_OPENDRAIN
#define PIO_OPENDRAIN (1 << 2) |
◆ PIO_OUTPUT_0
The pin is an output and has a default level of 0.
◆ PIO_OUTPUT_1
The pin is an output and has a default level of 1.
◆ PIO_PERIPH_A
The pin is controlled by the associated signal of peripheral A.
◆ PIO_PERIPH_B
The pin is controlled by the associated signal of peripheral B.
◆ PIO_PERIPH_C
The pin is controlled by the associated signal of peripheral C.
◆ PIO_PERIPH_D
The pin is controlled by the associated signal of peripheral D.
◆ PIO_PULLUP
#define PIO_PULLUP (1 << 0) |
The internal pin pull-up is active.
◆ PIO_WPMR_WPEN_DIS
#define PIO_WPMR_WPEN_DIS (0x00 << 0) |
◆ PIO_WPMR_WPEN_EN
#define PIO_WPMR_WPEN_EN (0x01 << 0) |
◆ PIO_WPMR_WPKEY_VALID
#define PIO_WPMR_WPKEY_VALID (0x50494F << 8) |
◆ PIO_Clear()
void PIO_Clear |
( |
const Pin * |
pin | ) |
|
Sets a low output level on all the PIOs defined in the given Pin instance. This has no immediate effects on PIOs that are not output, but the PIO controller will memorize the value they are changed to outputs.
- Parameters
-
pin | Pointer to a Pin instance describing one or more pins. |
◆ PIO_Configure()
uint8_t PIO_Configure |
( |
const Pin * |
list, |
|
|
uint32_t |
size |
|
) |
| |
Configures a list of Pin instances, each of which can either hold a single pin or a group of pins, depending on the mask value; all pins are configured by this function. The size of the array must also be provided and is easily computed using PIO_LISTSIZE whenever its length is not known in advance.
- Parameters
-
list | Pointer to a list of Pin instances. |
size | Size of the Pin list (calculated using PIO_LISTSIZE). |
- Returns
- 1 if the pins have been configured properly; otherwise 0.
◆ PIO_DisableWriteProtect()
void PIO_DisableWriteProtect |
( |
const Pin * |
pin | ) |
|
Disable write protect.
- Parameters
-
pin | Pointer to a Pin instance describing one or more pins. |
◆ PIO_EnableWriteProtect()
void PIO_EnableWriteProtect |
( |
const Pin * |
pin | ) |
|
Enable write protect.
- Parameters
-
pin | Pointer to a Pin instance describing one or more pins. |
◆ PIO_Get()
uint8_t PIO_Get |
( |
const Pin * |
pin | ) |
|
Returns 1 if one or more PIO of the given Pin instance currently have a high level; otherwise returns 0. This method returns the actual value that is being read on the pin. To return the supposed output value of a pin, use PIO_GetOutputDataStatus() instead.
- Parameters
-
pin | Pointer to a Pin instance describing one or more pins. |
- Returns
- 1 if the Pin instance contains at least one PIO that currently has a high level; otherwise 0.
◆ PIO_GetOutputDataStatus()
uint8_t PIO_GetOutputDataStatus |
( |
const Pin * |
pin | ) |
|
Returns 1 if one or more PIO of the given Pin are configured to output a high level (even if they are not output). To get the actual value of the pin, use PIO_Get() instead.
- Parameters
-
pin | Pointer to a Pin instance describing one or more pins. |
- Returns
- 1 if the Pin instance contains at least one PIO that is configured to output a high level; otherwise 0.
◆ PIO_GetWriteProtectViolationInfo()
uint32_t PIO_GetWriteProtectViolationInfo |
( |
const Pin * |
pin | ) |
|
Get write protect violation information.
- Parameters
-
pin | Pointer to a Pin instance describing one or more pins. |
◆ PIO_Set()
void PIO_Set |
( |
const Pin * |
pin | ) |
|
Sets a high output level on all the PIOs defined in the given Pin instance. This has no immediate effects on PIOs that are not output, but the PIO controller will memorize the value they are changed to outputs.
- Parameters
-
pin | Pointer to a Pin instance describing one or more pins. |
◆ PIO_SetDebounceFilter()
void PIO_SetDebounceFilter |
( |
const Pin * |
pin, |
|
|
uint32_t |
cuttoff |
|
) |
| |
Configures Glitch or Denouncing filter for input.
- Parameters
-
pin | Pointer to a Pin instance describing one or more pins. |
cuttoff | Cut off frequency for denounce filter. |
◆ PIO_SetDriveStrength()
void PIO_SetDriveStrength |
( |
const Pin * |
pin, |
|
|
uint8_t |
strength |
|
) |
| |
Set the drive strength of the pin.
- Parameters
-
pin | Pointer to a Pin instance describing one or more pins. |
strength | 0 for low drive strength or 1 for high drive strength. |
◆ PIO_SetPinType()
void PIO_SetPinType |
( |
Pin * |
pin, |
|
|
uint8_t |
pinType |
|
) |
| |
Set pin type the pin is controlled by the corresponding peripheral (A, B, C, D,E)
- Parameters
-
pin | Pointer to a Pin instance describing one or more pins. |
pinType | PIO_PERIPH_A, PIO_PERIPH_B, ... |