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 
9 #pragma once
10 
46 #include <stdbool.h>
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
55 #ifndef PIO_DEV
56 #define PIO_DEV(x) (x)
57 #endif
58 
63 #define PIO_PROGRAM_NOT_LOADED (-1)
64 
70 struct pio_isr_vec;
71 
75 typedef unsigned pio_t;
76 
80 typedef int pio_sm_t;
81 
85 typedef struct {
86  unsigned instr_numof;
87  int location;
88  bool written;
90 
99 void pio_init(pio_t pio);
100 
108 
118 
126 
134 
141 void pio_sm_stop(pio_t pio, pio_sm_t sm);
142 
154 
170 
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 
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:70
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:80
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:726
Struct that models a PIO program.
Definition: pio.h:85
int location
Program location in memory.
Definition: pio.h:87
unsigned instr_numof
Number of instructions.
Definition: pio.h:86
bool written
Program was already written.
Definition: pio.h:88