OpenShoe
1.0
|
High level external user interface (USB). More...
#include <string.h>
#include "external_interface.h"
#include "control_tables.h"
#include "conf_usb.h"
#include "udd.h"
#include "udc.h"
#include "udi_cdc.h"
#include "usbc_device.h"
Data Structures | |
struct | rxtx_buffer |
Receive and transmit buffer. | |
Defines | |
#define | CHECKSUM_BYTES 2 |
#define | HEADER_BYTES 1 |
#define | MAX_COMMAND_ARGS 10 |
#define | NO_EXPECTED_BYTES 0 |
#define | SINGLE_BYTE_EXPECTED 1 |
#define | USB_TIMEOUT_COUNT 200000000 |
#define | NO_INITIATED_TRANSMISSION 0 |
#define | COUNTER_RESET_VALUE 0 |
#define | NO_BYTES_RECEIVED_YET 0 |
#define | STATE_OUTPUT_HEADER 0xAA |
#define | receive_limit_not_reached(rx_nrb_counter) ((rx_nrb_counter)<MAX_RX_NRB) |
#define | reset_timer(timer) ((timer) = Get_system_register(AVR32_COUNT)) |
#define | is_new_header(exp_nrb) ((exp_nrb) == NO_EXPECTED_BYTES) |
#define | is_end_of_command(exp_nrb) (exp_nrb) == SINGLE_BYTE_EXPECTED |
#define | has_timed_out(timeout_counter, exp_nrb) ((timeout_counter) + USB_TIMEOUT_COUNT < Get_system_register(AVR32_COUNT) && (exp_nrb) > 0) |
#define | increment_counter(counter) ((counter)++) |
#define | decrement_counter(counter) ((counter)--) |
#define | FIRST_PAYLOAD_BYTE (state_output_header_p+2) |
#define | PAYLOAD_SIZE_BYTE (state_output_header_p+1) |
Buffer settings | |
#define | RX_BUFFER_SIZE 20 |
#define | TX_BUFFER_SIZE 60 |
#define | SINGLE_TX_BUFFER_SIZE 10 |
#define | MAX_RX_NRB 10 |
State output divider limits | |
#define | MAX_LOG2_DIVIDER 14 |
#define | MIN_LOG2_DIVIDER 0 |
Functions | |
void | com_interface_init (void) |
Initialization function for communication interface. | |
void | receive_command (void) |
Main function for receiving commands from user. | |
void | transmit_data (void) |
Main function to output data to user. | |
void | set_state_output (uint8_t state_id, uint8_t divider) |
Sets state_id state to be output with interrupt frequency divided by 2^(divider-1). Divider=0 turns off output. | |
void | reset_output_counters (void) |
Reset the output counter such that the output become synchronized. | |
Variables | |
uint8_t | error_signal = 0 |
Error signaling vector. If zero no error has occurred. | |
State output rate control variables |
High level external user interface (USB).
This file contains the functions for 1) receiving and parsing commands and executing commands responses 2) determining what to transmit and to transmit data to the system user via USB.
#define CHECKSUM_BYTES 2 |
#define COUNTER_RESET_VALUE 0 |
#define decrement_counter | ( | counter | ) | ((counter)--) |
#define FIRST_PAYLOAD_BYTE (state_output_header_p+2) |
#define has_timed_out | ( | timeout_counter, | |
exp_nrb | |||
) | ((timeout_counter) + USB_TIMEOUT_COUNT < Get_system_register(AVR32_COUNT) && (exp_nrb) > 0) |
#define HEADER_BYTES 1 |
#define increment_counter | ( | counter | ) | ((counter)++) |
#define is_end_of_command | ( | exp_nrb | ) | (exp_nrb) == SINGLE_BYTE_EXPECTED |
#define is_new_header | ( | exp_nrb | ) | ((exp_nrb) == NO_EXPECTED_BYTES) |
#define MAX_COMMAND_ARGS 10 |
#define NO_BYTES_RECEIVED_YET 0 |
#define NO_EXPECTED_BYTES 0 |
#define NO_INITIATED_TRANSMISSION 0 |
#define PAYLOAD_SIZE_BYTE (state_output_header_p+1) |
#define receive_limit_not_reached | ( | rx_nrb_counter | ) | ((rx_nrb_counter)<MAX_RX_NRB) |
#define reset_timer | ( | timer | ) | ((timer) = Get_system_register(AVR32_COUNT)) |
#define SINGLE_BYTE_EXPECTED 1 |
#define STATE_OUTPUT_HEADER 0xAA |
#define USB_TIMEOUT_COUNT 200000000 |