firmware  v0.1.2
Chromation Spectrometer Dev-Kit
Functions
UsbCmd.h File Reference
#include "StatusCode.h"
#include "ReadWriteBits.h"
#include "BiColorLed.h"
#include "Usb.h"
#include "SpiMaster.h"

Go to the source code of this file.

Functions

uint8_t ReadLedState (void)
 
void NullCommand (void)
 
void GetBridgeLED (void)
 
void SetBridgeLED (void)
 
void GetSensorLED (void)
 
void SetSensorLED (void)
 
void GetSensorConfig (void)
 
void SetSensorConfig (void)
 
void GetExposure (void)
 
void SetExposure (void)
 
void CaptureFrame (void)
 
void AutoExposure (void)
 
void GetAutoExposeConfig (void)
 
void SetAutoExposeConfig (void)
 
void GetSensorHash (void)
 

Detailed Description

API for usb-bridge.c

Definition in file UsbCmd.h.

Function Documentation

◆ CaptureFrame()

void CaptureFrame ( void  )
inline

CaptureFrame behavior:

  • sends command to sensor
  • writes OK to indicate it sent the command to the sensor
  • waits for sensor to signal STATUS data ready
  • reads status from sensor
  • waits for sensor to signal NUM_PIXELS_MSB data ready
  • reads num_pixels_MSB from sensor
  • waits for sensor to signal NUM_PIXELS_LSB data ready
  • reads num_pixels_LSB from sensor
  • writes sensor status
  • writes num_pixels_MSB
  • writes num_pixels_LSB
  • returns if status is not OK
  • waits for the next byte of frame data
  • writes the next byte of frame data
  • loops wait for byte then write byte for a total nbytes of 2x num_pixels

Definition at line 514 of file UsbCmd.h.

◆ GetBridgeLED()

void GetBridgeLED ( void  )
inline

GetBridgeLED behavior:

  • waits for byte led num
  • reads byte led num
  • writes two bytes to USB host
  • writes OK and LED STATE if led num is valid
  • writes ERROR and pads second byte if led num is invalid

Definition at line 53 of file UsbCmd.h.

◆ GetExposure()

void GetExposure ( void  )
inline

GetExposure behavior:

  • sends command to sensor
  • writes OK to indicate it sent the command to the sensor
  • waits for sensor to signal STATUS data ready
  • reads status from sensor
  • waits for sensor to signal EXPOSURE MSB data ready
  • reads exposure MSB from sensor
  • waits for sensor to signal EXPOSURE LSB data ready
  • reads exposure LSB from sensor
  • writes sensor status
  • writes exposure MSB
  • writes exposure LSB

Definition at line 422 of file UsbCmd.h.

◆ GetSensorConfig()

void GetSensorConfig ( void  )
inline

Forward 1-byte sensor config command to sensor.
Respond with five bytes:

  • usb-bridge status
    • send OK after sending all bytes to sensor
  • vis-spi-out status
    • If vis-spi-out status is ERROR, the next three bytes (binning, gain, and row_bitmap)
      contain garbage and should be ignored by the host application.
  • binning
  • gain
  • row_bitmap

GetSensorConfig behavior:

  • sends command to sensor
  • writes OK to indicate it sent the command to the sensor
  • waits for sensor to signal STATUS data ready
  • reads status from sensor
  • proceed reading from sensor if status is OK:
    • waits for sensor to signal BINNING data ready
    • reads binning from sensor
    • waits for sensor to signal GAIN data ready
    • reads gain from sensor
    • waits for sensor to signal ROW_BITMAP data ready
    • reads row_bitmap from sensor
  • writes sensor status
  • writes sensor binning
  • writes sensor gain
  • writes sensor row_bitmap

Definition at line 229 of file UsbCmd.h.

◆ GetSensorLED()

void GetSensorLED ( void  )
inline

Forward 2-byte indicator-LED command to sensor.
Respond with three bytes:

  • usb-bridge status
    • send OK after sending all bytes to sensor
  • vis-spi-out status
  • led_setting

GetSensorLED behavior:

  • waits for byte led num
  • reads byte led num
  • sends command to sensor
  • sends led num to sensor
  • writes OK to indicate it sent the command to the sensor
  • waits for sensor to signal STATUS data ready
  • reads status from sensor
  • waits for sensor to signal LED SETTING data ready
  • reads led setting from sensor
  • writes sensor status
  • writes sensor led setting

Definition at line 124 of file UsbCmd.h.

◆ NullCommand()

void NullCommand ( void  )
inline

Do nothing.

Definition at line 50 of file UsbCmd.h.

◆ ReadLedState()

uint8_t ReadLedState ( void  )
inline

ReadLedState behavior:

  • returns OFF if LED is off
  • returns GREEN if LED is on and green
  • returns RED if LED is on and red
  • see led_state in StatusCodes.h

LED 0, the status_led, is the only indicator LED on the usb-bridge.

Definition at line 30 of file UsbCmd.h.

◆ SetBridgeLED()

void SetBridgeLED ( void  )
inline

SetBridgeLED behavior:

  • waits for byte led num
  • reads byte led num
  • waits for byte led setting
  • reads byte led setting
  • applies led setting and writes OK if parameters are valid
  • writes ERROR if led num is invalid
  • writes ERROR if led setting is invalid

Definition at line 82 of file UsbCmd.h.

◆ SetExposure()

void SetExposure ( void  )
inline

SetExposure behavior:

  • waits for byte exposure_MSB
  • reads byte exposure_MSB
  • waits for byte exposure_LSB
  • reads byte exposure_LSB
  • sends command to sensor
  • sends exposure_MSB to sensor
  • sends exposure_LSB to sensor
  • writes OK to indicate it sent the command to the sensor
  • waits for sensor to signal STATUS data ready
  • reads status from sensor
  • writes sensor status

Definition at line 466 of file UsbCmd.h.

◆ SetSensorConfig()

void SetSensorConfig ( void  )
inline

Forward 4-byte sensor config command to sensor.
Respond with two bytes:

  • usb-bridge status
    • send OK after sending all bytes to sensor
  • vis-spi-out status
    • Status is OK if config is loaded.
    • Status is ERROR if
      • the config is invalid
      • or the SetSensorConfig command is unrecognized:
        • command SetSensorConfig is only defined for spectrometers using the LIS-770i

If the vis-spi-out status is ERROR, there are two possible causes.
But status does not include a message, it is either OK or ERROR.
The host application should, therefore, tell the user to troubleshoot both possible causes if status is ERROR.

Tell the user to:

  1. Check the connected spectrometer uses the LIS-770i:
    • call getSensorHash()
    • expect hash is 0x351ea9
  2. If the spectrometer does use the LIS-770i, check the config is valid:
    • valid config has three bytes:
      • [BINNING, GAIN, ACTIVE_ROWS]
    • BINNING is 0x00 or 0x01
    • GAIN is 0x01, 0x25, 0x04, or 0x05
    • (ACTIVE_ROWS & 0xE0) == 0x00

In the following description of SetSensorConfig behavior:

  • write and read refer to USB communication with the host application
  • send refers to communication with the sensor

SetSensorConfig behavior:

  • waits for byte binning
  • reads byte binning
  • waits for byte gain
  • reads byte gain
  • waits for byte row bitmap
  • reads byte row bitmap
  • sends command to sensor
  • waits for sensor to signal it recognizes the command
  • proceeds with sending config if sensor status is OK
    • sends binning to sensor
    • sends gain to sensor
    • sends row bitmap to sensor
    • waits for sensor to signal STATUS data ready
    • reads status from sensor
  • writes OK to indicate it sent the command to the sensor
  • writes sensor status

Definition at line 307 of file UsbCmd.h.

◆ SetSensorLED()

void SetSensorLED ( void  )
inline

Forward 3-byte indicator-LED command to sensor.
Respond with two bytes:

  • usb-bridge status
    • send OK after sending all bytes to sensor
  • vis-spi-out status

SetSensorLED behavior:

  • waits for byte led num
  • reads byte led num
  • waits for byte led setting
  • reads byte led setting
  • sends command to sensor
  • sends led num to sensor
  • sends led setting to sensor
  • writes OK to indicate it sent the command to the sensor
  • waits for sensor to signal STATUS data ready
  • reads status from sensor
  • writes sensor status

Definition at line 175 of file UsbCmd.h.