18 #ifndef SCAMP5C_SPI_HOST_HPP 
   19 #define SCAMP5C_SPI_HOST_HPP 
   22 #include "jcStopwatch.hpp" 
   25 #define SPI_PACKET_TYPE_STANDARD_LOOPC      4 
   26 #define SPI_PACKET_TYPE_STANDARD_AOUT       5 
   27 #define SPI_PACKET_TYPE_STANDARD_DOUT       6 
   28 #define SPI_PACKET_TYPE_STANDARD_TARGET     7 
   29 #define SPI_PACKET_TYPE_STANDARD_EVENTS     8 
   30 #define SPI_PACKET_TYPE_STANDARD_APPINFO    10 
   32 #define S5C_SPI_UNKNOWN     0 
   33 #define S5C_SPI_LOOPC       1 
   34 #define S5C_SPI_AOUT        2 
   35 #define S5C_SPI_DOUT        3 
   36 #define S5C_SPI_TARGET      4 
   37 #define S5C_SPI_EVENTS      5 
   38 #define S5C_SPI_APPINFO     6 
  184         return original_packet;
 
  192         Scamp5spi->ipu_port_forward[i] = u;
 
  196     inline uint32_t GetPacketCount(){
 
  197         return host_packet_count;
 
  199     inline double GetPacketRate(){
 
  200         return host_packet_rate;
 
  203     inline uint32_t GetLoopCounter(){
 
  206     inline uint32_t GetLoopCounterError(){
 
  207         return loop_counter_error;
 
  210     void RegisterErrorCallback(std::function<
void(
Scamp5cHost*)> func);
 
  211     void ResetCounters();
 
  212     int SaveFrameBMP(
const char*filepath);
 
  228     jcStopwatch PacketStopwatch;
 
  229     double host_packet_rate;
 
  230     double host_packet_rate_e;
 
  231     uint32_t host_packet_count;
 
  237     uint8_t *data_buffer;
 
  238     uint32_t loop_counter;
 
  239     int loop_counter_error;
 
  241     std::function<void(Scamp5cHost*)> standard_output_callback[8];
 
  242     std::function<void(Scamp5cHost*)> generic_packet_callback;
 
  243     std::function<void(Scamp5cHost*)> error_callback;
 
  245     struct std_loopc_meta{
 
  246         uint32_t loop_counter;
 
  248     struct std_events_meta{
 
  249         uint32_t loop_counter;
 
  250         uint16_t event_dimension;
 
  251         uint16_t event_count;
 
  253     struct std_aout_meta{
 
  254         uint32_t loop_counter;
 
  258     struct std_dout_meta{
 
  259         uint32_t loop_counter;
 
  263     struct std_target_meta{
 
  264         uint32_t loop_counter;
 
  267     inline uint8_t&data(
size_t r,
size_t c){
 
  268         return *(data_buffer + r*data_dim_c + c);
 
  271     inline void format_data_buffer(
size_t r,
size_t c){
 
  277         data_buffer = (uint8_t*)malloc(
sizeof(uint8_t)*data_dim_r*data_dim_c);
 
  280     void update_loop_counter(uint32_t new_lc);
 
  281     void update_packet_rate(uint32_t n);
 
  290     static int save_bmp24(
const char*filename,uint32_t width,uint32_t height,
const uint8_t*data);
 
uint32_t GetDataDim(int d)
this function can only be used within a packet callback function to get the dimension of the data ...
Definition: Scamp5cHost.hpp:145
 
void Open()
open the spi interface and initialize the host 
 
void SetInputPort(int i, uint8_t u)
set the value of SPI_RX_* port on the IPU 
Definition: Scamp5cHost.hpp:191
 
this interface uses the data-ready pin to trigger transfers. 
Definition: scamp5c_spi_versions.hpp:29
 
the SPI packet class 
Definition: scamp5c_spi.hpp:73
 
void Process()
process any present packet 
 
void SetupSpi(scamp5c_spi_ht *spi_class)
assign the SPI interface class to operate upon 
 
the SPI interface hosting class 
Definition: Scamp5cHost.hpp:47
 
uint8_t * GetData()
this function can only be used within a packet callback function to get the data 
Definition: Scamp5cHost.hpp:170
 
void Close()
close the spi interface and terminate the host 
 
scamp5c_spi::packet * GetPacket()
get the orgininal packet class received (can be used only in packet callback) 
Definition: Scamp5cHost.hpp:183
 
void RegisterGenericPacketCallback(std::function< void(Scamp5cHost *)> func)
register a function to be called when a generic packet is received 
 
void RegisterStandardOutputCallback(int type, std::function< void(Scamp5cHost *)> func)
register a function to be called when a type of standard packet is received