firmware  v0.1.2
Chromation Spectrometer Dev-Kit
Macros | Functions | Variables
vis-spi-out.c File Reference
#include "Hardware.h"
#include "StatusCodes.h"
#include "BiColorLed.h"
#include "Spi.h"
#include "SpiSlave.h"
#include "UartSpi.h"
#include <stdlib.h>
#include "Queue.h"
#include "VisCmd.h"

Go to the source code of this file.

Macros

#define max_length_of_queue   24
 Maximum size of the Queue's FIFO buffer is 24 bytes.
 

Functions

static void setup (void)
 
static void loop (void)
 
static void setup_IndicatorLEDs (void)
 
static void setup_SpiCommunication (void)
 
static void setup_DetectorReadout (void)
 
int main ()
 
 ISR (SPI_STC_vect)
 

Variables

volatile Queue_sSpiFifo
 Allocate static memory for the SPI Rx Queue.
 
volatile uint8_t spi_rx_buffer [max_length_of_queue]
 Allocate static memory for the Queue's FIFO buffer.
 

Function Documentation

◆ ISR()

ISR ( SPI_STC_vect  )

Interrupt when a SPI transfer completes:

  • push received byte onto SpiFifo (Queue head advances)
  • return from interrupt

    Interrupt disabled during SpiSlaveTxByte.
    Interrupt enabled all other times.

Definition at line 98 of file vis-spi-out.c.

◆ setup_DetectorReadout()

void setup_DetectorReadout ( void  )
static

Setup control of the ADC and the LIS-770i detector.

  • Configure UART module as a SPI Master to the ADC:
    • use a 5MHz clock to pull bits out of ADC
    • pin UartSpi_AdcConv: output, idle LOW
    • see details in UartSpiInit()
  • Configure I/O pins to control LIS-770i detector:
    • clock LIS-770i at 50kHz
    • pins Lis_PixSelect and Lis_Rst: output, idle LOW
    • see details in LisInit()
  • Set initial exposure time to 1 millisecond.
  • Set initial LIS-770i configuration:
    • binning on
    • gain 1x
    • all rows active
    • see LIS-770i cfg byte code definitions in LisConfigs.h
  • Program LIS-770i with initial configuration.

Definition at line 137 of file vis-spi-out.c.

◆ setup_IndicatorLEDs()

void setup_IndicatorLEDs ( void  )
static

Initialize PCB indicator LEDs

Definition at line 109 of file vis-spi-out.c.

◆ setup_SpiCommunication()

void setup_SpiCommunication ( void  )
static

Set up SPI hardware module and a FIFO to buffer bytes sent from the SPI master.

  • Configure SPI hardware module:
    • configure microcontroller as a SPI slave
    • pin Spi_DataReady: output, idle HIGH
    • pin Spi_Miso: output
    • enable interrupt on SPI Serial Transfer Complete (SPI_STC_vect)
    • see details in SpiSlaveInit()
  • Create a FIFO Queue to buffer up to 11 bytes of SPI data:

Definition at line 117 of file vis-spi-out.c.