uC chip interface arduino  0.9.0
A interface for async and neuromrphic IC testing
Loading...
Searching...
No Matches
interface_AER_from_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
20#ifndef AER_from_chip_H
21#define AER_from_chip_H
22
23#include <Arduino.h>
24#include "misc_functions.h"
25#include "core_ring_buffer.h"
26#include "interface_pin.h"
27#include "datatypes.h"
28#include "uc_boards.h"
30
32 /*
33 the AER_from_chip class handles the flexible and runtime assignable 4 phase handshake protocols for reciving data with the uC.
34 all the configuration is static and the moment the interface is activated an instance of this class is created and the
35 refenence stored in the static array AER_from_chip.
36 the following settings can be configured for each interface:
37 data pins locations, width from 0-32, a multiple of 20ns delay on the request line, if the data or handshake signals are active low
38 */
39
40 public:
41 /*
42 the configure class method handles incomming configuration packets, and also instatiactes the class on activation
43 requires:
44 id - the id of the interface the config is intended for
45 config - the config sub header that determines what is configured
46 data - the associated data to the configuration (if required by the config otherwise ignored)
47 */
48 static void configure(uint8_t id, uint8_t config, uint8_t data);
49
50 /*
51 the static configuration stoarge for the interfaces,
52 as the configuration is send in packets that can appear in random order or be incomplete
53 they are stored staticly in the class untill the interface is activated
54 */
55 static volatile uint8_t data_pins[8][32];
56 static volatile uint8_t data_width[8];
57 static volatile uint8_t req_pin[8];
58 static volatile uint8_t ack_pin[8];
59 static volatile uint8_t req_delay[8];
60 static volatile bool hs_lowactive[8];
61 static volatile bool data_lowactive[8];
62 static volatile bool active[8];
63 static volatile uint8_t type[8];
64 static volatile uint8_t port[8];
65 /*
66 the pointers to the interface instantces after activation.
67 */
68 static volatile AER_from_chip* inst[8];
69
70 //-----------------------------------------------------------------------------------------------------------------------------------
71 // Class constructor; initialises the AER_from_chip object and sets up the relevant pins on Teensy
72 //-----------------------------------------------------------------------------------------------------------------------------------
73 AER_from_chip(uint8_t id, uint8_t reqPin, uint8_t ackPin, volatile uint8_t dataPins[], uint8_t numDataPins, uint8_t delay = 0,
74 bool activeLow = false, bool dataActiveLow = false, uint8_t type=ASYNC_4Phase_Chigh_Dhigh);
75
76
77 //----------------------------------------------------------------------------------------------------------------------------------
78 // reqRead: Reads REQ pin state
79 //----------------------------------------------------------------------------------------------------------------------------------
80 bool reqRead() volatile;
81
82 //----------------------------------------------------------------------------------------------------------------------------------
83 // ackWrite: Writes to ACK pin
84 //----------------------------------------------------------------------------------------------------------------------------------
85 void ackWrite(bool val) volatile;
86
87 //----------------------------------------------------------------------------------------------------------------------------------
88 // recordEvent: Records output events as they occur
89 //----------------------------------------------------------------------------------------------------------------------------------
90 void recordEvent() volatile;
91
92 //----------------------------------------------------------------------------------------------------------------------------------
93 // handshake: Executes REQ/ACK handshake between Teensy and chip
94 //----------------------------------------------------------------------------------------------------------------------------------
95 void handshake();
96
97 // ---------------------------------------------------- Declaring private methods --------------------------------------------------
98 protected:
99
100 uint32_t getData() volatile;
101 //----------------------------------------------------------------------------------------------------------------------------------
102 // setupPins: Sets up the relevant pins for communication
103 //----------------------------------------------------------------------------------------------------------------------------------
104 bool setupPins();
105
106 // --------------------------------------------------- Declaring private variables -------------------------------------------------
107
108 uint8_t _reqPin;
109 uint8_t _ackPin;
110 volatile uint8_t* _dataPins;
112 uint8_t _delay;
115 uint8_t _id;
116 uint8_t _type;
117
118};
119
120void aer_ISR(uint8_t id);
121void aer0_ISR();
122void aer1_ISR();
123void aer2_ISR();
124void aer3_ISR();
125void aer4_ISR();
126void aer5_ISR();
127void aer6_ISR();
128void aer7_ISR();
129
130#endif
static volatile AER_from_chip * inst[8]
volatile uint8_t * _dataPins
void ackWrite(bool val) volatile
static volatile uint8_t port[8]
uint32_t getData() volatile
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]
void recordEvent() volatile
static void configure(uint8_t id, uint8_t config, uint8_t data)
static volatile bool active[8]
static volatile uint8_t type[8]
static volatile uint8_t req_delay[8]
static volatile uint8_t req_pin[8]
static volatile uint8_t ack_pin[8]
void aer_ISR(uint8_t id)
void aer6_ISR()
void aer1_ISR()
void aer5_ISR()
void aer2_ISR()
void aer0_ISR()
void aer3_ISR()
void aer7_ISR()
void aer4_ISR()
@ ASYNC_4Phase_Chigh_Dhigh