SRA Board Components
ESP-IDF component for SRA Board
shift_register.h
Go to the documentation of this file.
1/*
2 * MIT License
3 *
4 * Copyright (c) 2025 Society of Robotics and Automation
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25#ifndef SHIFT_REGISTER_H
26#define SHIFT_REGISTER_H
27
28#include <stdint.h>
29#include <stdbool.h>
30#include <stdlib.h>
31
32#include "pin_defs.h"
33#include "utils.h"
34
35#include "driver/gpio.h"
36#include "hal/gpio_types.h"
37#include "driver/gptimer.h"
38#include "driver/gptimer_types.h"
39#include "esp_err.h"
40#include "esp_check.h"
41
45typedef struct {
46 gpio_num_t sdata;
47 gpio_num_t srclk;
48 gpio_num_t rclk;
49 gptimer_handle_t timer;
51
58
66esp_err_t shift_register_write_uint8(const shift_register_t *sreg, const uint8_t data, const bool instant);
67
75esp_err_t shift_register_write_uint32(const shift_register_t *sreg, const uint32_t data, const bool instant);
76
83
84#endif
esp_err_t shift_register_write_uint8(const shift_register_t *sreg, const uint8_t data, const bool instant)
Writes a single byte to the shift register and latches it (single shift register)
Definition: shift_register.c:122
esp_err_t shift_register_gpio_init(shift_register_t *conf)
Initialises the GPIO Pins for the Shift Register Present on the SRA Board.
Definition: shift_register.c:36
esp_err_t shift_register_write_uint32(const shift_register_t *sreg, const uint32_t data, const bool instant)
Writes a four bytes to the shift register and latches it (four cascaded shift registers)
Definition: shift_register.c:150
esp_err_t shift_register_cleanup(shift_register_t sreg)
Performs cleanup on the shift register contents.
Definition: shift_register.c:178
The handle used for representing the shift register.
Definition: shift_register.h:45
gptimer_handle_t timer
Definition: shift_register.h:49
gpio_num_t rclk
Definition: shift_register.h:48
gpio_num_t sdata
Definition: shift_register.h:46
gpio_num_t srclk
Definition: shift_register.h:47