uC chip interface arduino  0.9.0
A interface for async and neuromrphic IC testing
Loading...
Searching...
No Matches
interface_async.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_funtions.h"
25#include "core_ring_buffer.h"
26#include "Interface_pin.h"
27#include "datatypes.h"
28#include "uc_boards.h"
29
30enum Async_from_chip_types : uint8_t {
32 //AER_TEENSY_BANK = 1U,
34};
35
36class Async {
37 /*
38 the AER_from_chip class handles the flexible and runtime assignable 4 phase handshake protocols for reciving data with the uC.
39 all the configuration is static and the moment the interface is activated an instance of this class is created and the
40 refenence stored in the static array AER_from_chip.
41 the following settings can be configured for each interface:
42 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
43 */
44
45 public:
46 /*
47 the configure class method handles incomming configuration packets, and also instatiactes the class on activation
48 requires:
49 id - the id of the interface the config is intended for
50 config - the config sub header that determines what is configured
51 data - the associated data to the configuration (if required by the config otherwise ignored)
52 */
53 static void configure(uint8_t id, uint8_t config, uint8_t data);
54
55 /*
56 the static configuration stoarge for the interfaces,
57 as the configuration is send in packets that can appear in random order or be incomplete
58 they are stored staticly in the class untill the interface is activated
59 */
60 static volatile uint8_t data_pins[8][32];
61 static volatile uint8_t data_width[8];
62 static volatile uint8_t req_pin[8];
63 static volatile uint8_t ack_pin[8];
64 static volatile uint8_t req_delay[8];
65 static volatile bool active[8];
66 static volatile uint8_t type[8];
67 static volatile uint8_t port[8];
68 /*
69 the pointers to the interface instantces after activation.
70 */
71 static volatile Async_from_chip* inst[8];
72
73 static void async_ISR(uint8_t id);
74 static void async0_ISR();
75 static void async1_ISR();
76 static void async2_ISR();
77 static void async3_ISR();
78 static void async4_ISR();
79 static void async5_ISR();
80 static void async6_ISR();
81 static void async7_ISR();
82
83 //-----------------------------------------------------------------------------------------------------------------------------------
84 // Class constructor; initialises the AER_from_chip object and sets up the relevant pins on Teensy
85 //-----------------------------------------------------------------------------------------------------------------------------------
86 AER_from_chip(uint8_t id, uint8_t reqPin, uint8_t ackPin, uint8_t delay = 0);
87
88
89 virtual void request_isr() = 0;
90
91 protected:
92
93 virtual uint32_t record_data() = 0 volatile;
94 //----------------------------------------------------------------------------------------------------------------------------------
95 // setupPins: Sets up the relevant pins for communication
96 //----------------------------------------------------------------------------------------------------------------------------------
99
103
104
105 // --------------------------------------------------- Declaring private variables -------------------------------------------------
106
107 uint8_t _reqPin;
108 uint8_t _ackPin;
109 volatile uint8_t* _dataPins;
111 uint8_t _delay;
112 uint8_t _id;
113
114};
115
117{
118private:
119 /* data */
120public:
121 interface_async(/* args */);
123};
124
126{
127private:
128 /* data */
129public:
130 interface_async(/* args */);
132};
133
134interface_async::interface_async(/* args */)
135{
136}
137
138interface_async::~interface_async()
139{
140}
141
142
143
144
145#endif
static void async3_ISR()
uint8_t _ackPin
static volatile uint8_t ack_pin[8]
static volatile uint8_t req_delay[8]
bool setup_data_pins()
static void async7_ISR()
uint8_t _numDataPins
volatile uint8_t * _dataPins
bool setup_hs_pins()
static volatile uint8_t req_pin[8]
static volatile bool active[8]
static volatile uint8_t port[8]
static void async6_ISR()
static void async2_ISR()
static volatile uint8_t data_pins[8][32]
static void async0_ISR()
static void configure(uint8_t id, uint8_t config, uint8_t data)
static void async5_ISR()
uint8_t _delay
uint8_t _id
static void async1_ISR()
static volatile uint8_t data_width[8]
AER_from_chip(uint8_t id, uint8_t reqPin, uint8_t ackPin, uint8_t delay=0)
void exec_4_phase_active_low()
void exec_2_phase()
void exec_4_phase_active_high()
uint8_t _reqPin
static volatile Async_from_chip * inst[8]
virtual uint32_t record_data()=0 volatile
static void async4_ISR()
virtual void request_isr()=0
static volatile uint8_t type[8]
static void async_ISR(uint8_t id)
Async_from_chip_types
@ AER_FULL_CUSTOM
@ AER_MCP23017