pio.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Otto-von-Guericke Universität Magdeburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
44 #ifndef PERIPH_PIO_H
45 #define PERIPH_PIO_H
46 
47 #include <stdbool.h>
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
56 #ifndef PIO_DEV
57 #define PIO_DEV(x) (x)
58 #endif
59 
64 #define PIO_PROGRAM_NOT_LOADED (-1)
65 
71 struct pio_isr_vec;
72 
76 typedef unsigned pio_t;
77 
81 typedef int pio_sm_t;
82 
86 typedef struct {
87  unsigned instr_numof;
88  int location;
89  bool written;
91 
100 void pio_init(pio_t pio);
101 
109 
119 
127 
135 
142 void pio_sm_stop(pio_t pio, pio_sm_t sm);
143 
155 
171 
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif /* PERIPH_PIO_H */
void pio_sm_start(pio_t pio, pio_sm_t sm)
Start a state machine and execute the previously loaded program.
pio_sm_t pio_sm_lock(pio_t pio)
Get exclusive access to one of the state machines of PIO pio.
unsigned pio_t
PIO index type.
Definition: pio.h:71
void pio_init(pio_t pio)
Initialize a PIO device.
void pio_start_programs(void)
Start automatically configured PIO programs.
int pio_alloc_program_sm_lock_any(pio_t *pio_ptr, pio_sm_t *sm_ptr, pio_program_t *program)
Convenience function which performs the usual PIO program resource acquisition.
void pio_free_program(pio_t pio, pio_program_t *prog)
Release the allocated instruction memory occupied by prog.
int pio_sm_t
PIO state machine index type.
Definition: pio.h:81
void pio_sm_unlock(pio_t pio, pio_sm_t sm)
Release a previously locked state machine.
int pio_alloc_program(pio_t pio, pio_program_t *prog)
Allocate the required instruction memory to load the given PIO program into.
void pio_sm_stop(pio_t pio, pio_sm_t sm)
Stop the execution of a program.
PIO interrupt callbacks for FIFO interrupts.
Definition: pio.h:727
Struct that models a PIO program.
Definition: pio.h:86
int location
Program location in memory.
Definition: pio.h:88
unsigned instr_numof
Number of instructions.
Definition: pio.h:87
bool written
Program was already written.
Definition: pio.h:89