Ir Pulse Generator Pseudocode
Ir Pulse Generator Pseudocode
Ir Pulse Generator Pseudocode
// function: main
// initialize and read the team select pin. This pin tells us which team we are on, to set
comms frequency
// set as digital input
// read pin value
// if we are team A, set pulse length to 300us. Otherwise set to 500us
// set up the ‘request data transfer’ pin, so we can initiate messages to the gameplay
node
// set as digital output
LED_pin_setup
// set as digital output
// set pin low to start
// if we are in the ‘preamble’ portion of the message, set the timing to 1.5x
// else:
// if the transmission edge count is less than the number of edges we want to
transmit:
// set the timer for one period, to transmit the next edge
// else, we need to rest the edge count and transmit an end-of-message gap
// reset the transmission edge count
// set the timer for 8x period, to generate the pulse gap
IR_IC_HW_init
// set up interrupts
// clear interrupt flag
// set input capture priority
// turn on multiple interrupt vectors (MVEC)
// enable global interrupts
// enable local interrupt
// set a one-shot timer. This will reset the receiver_edge_count when we get the
pulse gap
// if we are *not* in active receiving mode, check that the period matches the
preamble period
// if it does:
// enter active receiving mode
// set the edge count to 1 - this is the first edge of the message
// otherwise:
// take no action