uC chip interface arduino  0.9.0
A interface for async and neuromrphic IC testing
Loading...
Searching...
No Matches
interface_AER_to_chip.h
Go to the documentation of this file.
1/*
2 This file is part of the Firmware project to interface with small Async or Neuromorphic chips
3 Copyright (C) 2022 Matteo Cartiglia - University of Zurich
4 Copyright (C) 2022-2023 Ole Richter - University of Groningen
5
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>.
18*/
19#ifndef AER_to_chip_H
20#define AER_to_chip_H
21
22#include <Arduino.h>
23#include "core_ring_buffer.h"
24#include "interface_pin.h"
25#include "datatypes.h"
26#include "misc_functions.h"
27
28#define AER_HANDSHAKE_TIMEOUT 1
29
30enum ASYNC_TYPE : uint8_t {
35};
36
37
39{
40 // ------------------------------------------ Declaring class constructor and public methods ----------------------------------------
41 public:
42
43 static void configure(uint8_t id, uint8_t config, uint8_t data);
44 static void send_packet(uint8_t id, uint32_t data, uint8_t header);
45
46 static volatile uint8_t data_pins[8][32];
47 static volatile uint8_t data_width[8];
48 static volatile uint8_t req_pin[8];
49 static volatile uint8_t ack_pin[8];
50 static volatile uint8_t req_delay[8];
51 static volatile uint8_t type[8];
52 static volatile bool hs_lowactive[8];
53 static volatile bool data_lowactive[8];
54 static volatile bool active[8];
55 static volatile AER_to_chip* inst[8];
56
57 //-----------------------------------------------------------------------------------------------------------------------------------
58 // Class constructor; initialises the AER_to_chip object and sets up the relevant pins on Teensy
59 //-----------------------------------------------------------------------------------------------------------------------------------
60 AER_to_chip(uint8_t id, uint8_t reqPin, uint8_t ackPin, volatile uint8_t dataPins[], uint8_t numDataPins, uint8_t delay = 0, bool activeLow = false);
61
62 //----------------------------------------------------------------------------------------------------------------------------------
63 // dataWrite: Executes REQ/ACK handshake and writes to ALIVE
64 //----------------------------------------------------------------------------------------------------------------------------------
65 bool dataWrite(uint32_t data) volatile;
66
67
68 // ---------------------------------------------------- Declaring private methods --------------------------------------------------
69
70 private:
71
72 //----------------------------------------------------------------------------------------------------------------------------------
73 // setupPins: Sets up the relevant pins for communication
74 //----------------------------------------------------------------------------------------------------------------------------------
75 bool setupPins();
76
77 //----------------------------------------------------------------------------------------------------------------------------------
78 // ackRead: Reads ACK pin state
79 //----------------------------------------------------------------------------------------------------------------------------------
80 bool ackRead() volatile;
81
82 //----------------------------------------------------------------------------------------------------------------------------------
83 // reqWrite: Writes to REQ pin
84 //----------------------------------------------------------------------------------------------------------------------------------
85 void reqWrite(bool val) volatile;
86
87 //----------------------------------------------------------------------------------------------------------------------------------
88 // setData: Write data to pins
89 //----------------------------------------------------------------------------------------------------------------------------------
90 void setData(uint32_t data) volatile;
91
92
93 // --------------------------------------------------- Declaring private variables -------------------------------------------------
94
95 uint8_t _reqPin;
96 uint8_t _ackPin;
97 volatile uint8_t* _dataPins;
98 uint8_t _numDataPins;
99 uint8_t _delay;
100 bool _activeLow;
101 uint8_t _id;
102};
103
104
105
106#endif
static void send_packet(uint8_t id, uint32_t data, uint8_t header)
static volatile bool data_lowactive[8]
static volatile uint8_t data_width[8]
static volatile bool hs_lowactive[8]
static volatile uint8_t data_pins[8][32]
static volatile AER_to_chip * inst[8]
static void configure(uint8_t id, uint8_t config, uint8_t data)
static volatile bool active[8]
static volatile uint8_t type[8]
bool dataWrite(uint32_t data) volatile
static volatile uint8_t req_delay[8]
static volatile uint8_t req_pin[8]
static volatile uint8_t ack_pin[8]
@ ASYNC_2Phase
@ ASYNC_4Phase_Chigh_Dhigh
@ ASYNC_4Phase_Clow_Dhigh
@ ASYNC_4Phase_MCP23017