71#define NEURON_ID_MASK 0x7FF
120 uint32_t direction_key = direction |
key;
121 while (!spin1_send_mc_packet(direction_key, the_speed,
WITH_PAYLOAD)) {
136 const char *direction,
const char *opposite) {
137 int direction_count =
counters[direction_index - 1];
138 int opposite_count =
counters[opposite_index - 1];
139 int delta = direction_count - opposite_count;
140 log_debug(
"%s = %d, %s = %d, delta = %d, threshold = %u",
141 direction, direction_count, opposite, opposite_count, delta,
155 log_debug(
"Motion is indeterminate in %s-%s direction",
156 direction, opposite);
171 const char *direction,
const char *opposite) {
172 int direction_speed =
last_speed[direction_index - 1];
173 int opposite_speed =
last_speed[opposite_index - 1];
174 int delta = direction_speed - opposite_speed;
176 log_debug(
"Resending %s = %d", direction, direction_speed);
178 }
else if (delta < 0) {
179 log_debug(
"Resending %s = %d", opposite, opposite_speed);
182 log_debug(
"Resending No Motion in the %s-%s direction", direction,
213 log_debug(
"Received spike from unknown neuron %d", nid);
241 log_info(
"Reading parameters from 0x%.8x", config_region);
259 log_info(
"Key = %d, speed = %d, sample_time = %d, update_time = %d,"
260 " delay_time = %d, delta_threshold = %d, continue_if_not_different = %d",
284 for (
uint count = 0; count < payload; count ++){
292 log_debug(
"writing other provenance data");
298 log_debug(
"finished other provenance data");
331 log_info(
"initialise: completed successfully");
341 log_error(
"Error in initialisation - exiting!");
data_specification_metadata_t * data_specification_get_data_address(void)
bool data_specification_read_header(data_specification_metadata_t *ds_regions)
void log_error(const char *message,...)
void log_debug(const char *message,...)
void log_info(const char *message,...)
static uint32_t timer_period
Used for configuring the timer hardware.
Functions for immediate handling of incoming spikes.
static bool in_spikes_get_next_spike(spike_t *spike)
Retrieves a spike from the input spike buffer.
static bool in_spikes_initialize_spike_buffer(uint32_t size)
This function initialises the input spike buffer.
static counter_t in_spikes_get_n_buffer_overflows(void)
Get the number of times that the input spike buffer overflowed.
static bool in_spikes_add_spike(spike_t spike)
Adds a spike to the input spike buffer.
Data type definitions for SpiNNaker Neuron-modelling.
uint32_t spike_t
The type of a spike.
#define NEURON_ID_MASK
Mask for selecting the neuron ID from a spike.
static int delta_threshold
The size of change required to matter.
static void c_main_store_provenance_data(address_t provenance_region)
Callback to store provenance data (format: neuron_provenance).
static uint32_t simulation_ticks
Current simulation stop/pause time.
static int speed
The standard motor speed, set by configuration.
static uint32_t delay_time
Inter-message delay time, in μs.
static bool initialize(uint32_t *timer_period)
Read all application configuration.
static int * counters
Accumulators for each motor direction.
uint32_t continue_if_not_different
Whether we should continue moving if there is no change.
static void do_update(direction_t direction_index, direction_t opposite_index, const char *direction, const char *opposite)
Commands the robot's motors to continue a motion started by do_motion()
static void incoming_spike_callback_payload(uint key, uint payload)
Add incoming spike message (in FIQ) to circular buffer.
static bool continue_if_not_different
Whether we should continue moving if there is no change.
static uint32_t key
The (base) key to use to send to the motor.
robot_motor_control_regions_e
DSG regions in use.
@ PARAMS_REGION
Configuration region for this application.
@ PROVENANCE_DATA_REGION
Provenance region for this application.
@ SYSTEM_REGION
General simulation API control area.
int delta_threshold
The size of change required to matter.
static uint32_t update_time
Time interval between updates, in ticks.
uint32_t delay_time
Outgoing inter-message delay time, in μs.
static void incoming_spike_callback(uint key, uint payload)
Add incoming spike message (in FIQ) to circular buffer.
static void do_motion(direction_t direction_index, direction_t opposite_index, const char *direction, const char *opposite)
Commands the robot's motors to start doing a motion.
static void send_to_motor(uint32_t direction, uint32_t the_speed)
Send a SpiNNaker multicast-with-payload message to the motor hardware.
static uint32_t infinite_run
True if the simulation is running continuously.
void c_main(void)
Entry point.
static void read_parameters(motor_control_config_t *config_region)
Reads the configuration.
static void timer_callback(uint unused0, uint unused1)
Regular 1ms callback. Takes spikes from circular buffer and converts to motor activity level.
uint32_t key
The (base) key to use to send to the motor.
static uint32_t sample_time
Time interval between samples, in ticks.
int speed
The standard motor speed scaling factor.
robot_motor_control_callback_priorities
values for the priority for each callback
@ TIMER
Timer interrupt processing is lowest priority.
@ DMA
DMA complete handling is medium priority.
@ MC
Multicast message reception is FIQ.
@ SDP
SDP handling is highest normal priority.
static int * last_speed
The last speeds for each motor direction.
uint32_t n_input_buffer_overflows
A count of the times that the synaptic input circular buffers overflowed.
static uint32_t time
The simulation time.
direction_t
The "directions" that the motors can move in.
@ MOTION_FORWARD
Forwards.
@ MOTION_C_CLOCKWISE
Rotate counterclockwise on the spot.
@ MOTION_RIGHT
To the right.
@ MOTION_CLOCKWISE
Rotate clockwise on the spot.
@ MOTION_LEFT
To the left.
#define N_COUNTERS
Number of counters.
uint32_t update_time
Time interval between motor speed updates, in ticks.
The structure of our configuration region in SDRAM.
The provenance information written on application shutdown.
void rt_error(uint code,...)
void simulation_handle_pause_resume(resume_callback_t callback)
void simulation_set_provenance_function(prov_callback_t provenance_function, address_t provenance_data_address)
bool simulation_is_finished(void)
void simulation_ready_to_read(void)
void simulation_run(void)
bool simulation_initialise(address_t address, uint32_t expected_application_magic_number, uint32_t *timer_period, uint32_t *simulation_ticks_pointer, uint32_t *infinite_run_pointer, uint32_t *time_pointer, int sdp_packet_callback_priority, int dma_transfer_complete_priority)
void spin1_callback_on(uint event_id, callback_t cback, int priority)