OpenOCD
protocol.c File Reference

Implementation of the OpenULINK communication protocol. More...

Include dependency graph for protocol.c:

Go to the source code of this file.

Functions

void command_loop (void)
 Forever wait for commands and execute them as they arrive. More...
 
bool execute_command (void)
 Executes one command and updates global command indexes. More...
 
void execute_set_led_command (void)
 Execute a SET_LEDS command. More...
 

Variables

volatile uint8_t cmd_id_index
 Index in EP2 Bulk-OUT data buffer that contains the current command ID. More...
 
volatile uint8_t payload_index_in
 Number of data bytes already in EP2 Bulk-IN buffer. More...
 

Detailed Description

Implementation of the OpenULINK communication protocol.

The OpenULINK protocol uses one OUT and one IN endpoint. These two endpoints are configured to use the maximum packet size for full-speed transfers, 64 bytes. Commands always start with a command ID (see msgtypes.h for command ID definitions) and contain zero or more payload data bytes in both transfer directions (IN and OUT). The payload

Almost all commands contain a fixed number of payload data bytes. The number of payload data bytes for the IN and OUT direction does not need to be the same.

Multiple commands may be sent in one EP2 Bulk-OUT packet. Because the OpenULINK firmware does not perform bounds checking for EP2 Bulk-IN packets, the host MUST ensure that the commands sent in the OUT packet require a maximum of 64 bytes of IN data.

Definition in file protocol.c.

Function Documentation

◆ command_loop()

void command_loop ( void  )

Forever wait for commands and execute them as they arrive.

Definition at line 193 of file protocol.c.

References CLEAR_COM_LED, cmd_id_index, EP2_in, EP2_out, execute_command(), payload_index_in, and SET_COM_LED.

Referenced by main().

◆ execute_command()

◆ execute_set_led_command()

void execute_set_led_command ( void  )

Execute a SET_LEDS command.

Definition at line 46 of file protocol.c.

References CLEAR_COM_LED, CLEAR_RUN_LED, cmd_id_index, COM_LED_OFF, COM_LED_ON, RUN_LED_OFF, RUN_LED_ON, SET_COM_LED, and SET_RUN_LED.

Referenced by execute_command().

Variable Documentation

◆ cmd_id_index

volatile uint8_t cmd_id_index

Index in EP2 Bulk-OUT data buffer that contains the current command ID.

Definition at line 38 of file protocol.c.

Referenced by command_loop(), execute_command(), and execute_set_led_command().

◆ payload_index_in

volatile uint8_t payload_index_in

Number of data bytes already in EP2 Bulk-IN buffer.

Definition at line 41 of file protocol.c.

Referenced by command_loop(), and execute_command().