#include <stddef.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <stdbool.h>#include "FifoBuffer.h"Go to the source code of this file.
Classes | |
| union | emitting_power_list_t |
| struct | slip_error_counter_s |
| struct | time_reference_t |
Macros | |
| #define | SIMULATOR |
| #define | main robot_main |
| #define | IR_RX_COUNT 4 |
| #define | MAX_PAYLOAD_SIZE_BYTES 382 |
| #define | MAX_NUMBER_OF_WORD 20 |
| #define | pogobot_infrared_emitter_power_max 3 |
| #define | pogobot_infrared_emitter_power_twoThird 2 |
| #define | pogobot_infrared_emitter_power_oneThird 1 |
| #define | pogobot_infrared_emitter_power_null 0 |
| #define | pogobot_infrared_emitter_width_bits 2 |
| #define | pogobot_infrared_emitting_power_list(front, right, back, left) |
| #define | get_infrared_emitter_dir(dir, emitting_power_list) |
| #define | pogobot_infrared_emitter_front_mask ( 1 << 0 ) |
| #define | pogobot_infrared_emitter_right_mask ( 1 << 8 ) |
| #define | pogobot_infrared_emitter_back_mask ( 1 << 16 ) |
| #define | pogobot_infrared_emitter_left_mask ( 1 << 24 ) |
| #define | pogobot_infrared_emitter_mask_byindex(index) |
| #define | NUMEL 20 |
| #define | init_from_configuration(x) |
| #define | init_array_from_configuration(a) |
| #define | printf pogosim_printf |
| #define | putchar pogosim_putchar |
Typedefs | |
| typedef union emitting_power_list_t | emitting_power_list_t |
| typedef struct message_header_t | message_header_t |
| typedef struct message_t | message_t |
| typedef struct message_short_header_t | message_short_header_t |
| typedef struct short_message_t | short_message_t |
| typedef struct time_reference_t | time_reference_t |
Enumerations | |
| enum | { pogobot_infrared_emitting_power_list_front_full , pogobot_infrared_emitting_power_list_right_full , pogobot_infrared_emitting_power_list_back_full , pogobot_infrared_emitting_power_list_left_full , pogobot_infrared_emitting_power_list_all_full } |
| enum | ir_direction { ir_front = 0 , ir_right = 1 , ir_back = 2 , ir_left = 3 , ir_all = 4 } |
| enum | ir_type_message { ir_t_cmd = 1 , ir_t_flash = 2 , ir_t_short = 3 , ir_t_user = 16 } |
| enum | photosensor_id { p_FL = 1 , p_FR = 2 , p_B = 0 } |
| enum | motor_id { motorR = 0 , motorL = 1 , motorB = 2 } |
| enum | motor_range { motorStop = 0 , motorQuarter = 256 , motorHalf = 512 , motorThreeQuarter = 716 , motorFull = 1023 } |
Functions | |
| void | pogobot_init (void) |
| FifoBuffer_typedef (message_t, Messagefifo) | |
| void | pogobot_infrared_ll_init (void) |
| void | pogobot_infrared_update (void) |
| int | pogobot_infrared_message_available (void) |
| void | pogobot_infrared_recover_next_message (message_t *mes) |
| void | pogobot_infrared_clear_message_queue (void) |
| void | pogobot_infrared_set_power (uint8_t power) |
| uint32_t | pogobot_infrared_sendRawLongMessage (message_t *const message) |
| uint32_t | pogobot_infrared_sendRawShortMessage (ir_direction dir, short_message_t *const message) |
| uint32_t | pogobot_infrared_sendLongMessage_uniSpe (ir_direction dir, uint8_t *message, uint16_t message_size) |
| uint32_t | pogobot_infrared_sendLongMessage_omniGen (uint8_t *message, uint16_t message_size) |
| uint32_t | pogobot_infrared_sendLongMessage_omniSpe (uint8_t *message, uint16_t message_size) |
| uint32_t | pogobot_infrared_sendShortMessage_uni (ir_direction dir, uint8_t *message, uint16_t message_size) |
| uint32_t | pogobot_infrared_sendShortMessage_omni (uint8_t *message, uint16_t message_size) |
| void | pogobot_infrared_get_receiver_error_counter (slip_error_counter_s *error_counter, uint8_t ir_index) |
| void | pogobot_infrared_reset_receiver_error_counter (void) |
| void | pogobot_led_setColor (const uint8_t r, const uint8_t g, const uint8_t b) |
| void | pogobot_led_setColors (const uint8_t r, const uint8_t g, const uint8_t b, uint8_t id) |
| int16_t | pogobot_photosensors_read (uint8_t sensor_number) |
| void | pogobot_imu_read (float *acc, float *gyro) |
| float | pogobot_imu_readTemp (void) |
| int16_t | pogobot_battery_voltage_read (void) |
| void | pogobot_motor_power_set (motor_id motor, uint16_t value) |
| void | pogobot_motor_set (motor_id motor, uint16_t value) |
| uint32_t | pogobot_motor_dir_current_status (void) |
| int8_t | pogobot_motor_dir_mem_get (uint8_t *p_directions) |
| int8_t | pogobot_motor_dir_mem_set (uint8_t *p_directions) |
| void | pogobot_motor_dir_set (motor_id motor, uint8_t value) |
| uint8_t | pogobot_motor_power_mem_get (uint16_t *p_powers) |
| uint8_t | pogobot_motor_power_mem_set (uint16_t *p_powers) |
| uint16_t | pogobot_helper_getid (void) |
| int16_t | pogobot_helper_getRandSeed (void) |
| void | pogobot_helper_print_version (void) |
| void | pli_timer_sleep_stopwatch_init (void) |
| void | pogobot_stopwatch_reset (time_reference_t *stopwatch) |
| int32_t | pogobot_stopwatch_lap (time_reference_t *stopwatch) |
| int32_t | pogobot_stopwatch_get_elapsed_microseconds (time_reference_t *stopwatch) |
| void | pogobot_stopwatch_offset_origin_microseconds (time_reference_t *stopwatch, int32_t microseconds_offset) |
| void | pogobot_timer_init (time_reference_t *timer, int32_t microseconds_to_go) |
| int32_t | pogobot_timer_get_remaining_microseconds (time_reference_t *timer) |
| bool | pogobot_timer_has_expired (time_reference_t *timer) |
| void | pogobot_timer_wait_for_expiry (time_reference_t *timer) |
| void | pogobot_timer_offset_origin_microseconds (time_reference_t *timer, int32_t microseconds_offset) |
| void | msleep (int milliseconds) |
| void | pogosim_printf (const char *format,...) |
| int | pogosim_putchar (int ch) |
| uint32_t | get_nb_robots (void) |
| void | stop_simulation (void) |
| void | data_add_column_int8 (char const *name) |
| void | data_add_column_int16 (char const *name) |
| void | data_add_column_int32 (char const *name) |
| void | data_add_column_int64 (char const *name) |
| void | data_add_column_double (char const *name) |
| void | data_add_column_string (char const *name) |
| void | data_add_column_bool (char const *name) |
| void | data_add_column_float16 (char const *name) |
| void | enable_data_export (void) |
| void | disable_data_export (void) |
| void | data_set_value_int8 (char const *name, int8_t value) |
| void | data_set_value_int16 (char const *name, int16_t value) |
| void | data_set_value_int32 (char const *name, int32_t value) |
| void | data_set_value_int64 (char const *name, int64_t value) |
| void | data_set_value_double (char const *name, double value) |
| void | data_set_value_string (char const *name, char const *value) |
| void | data_set_value_bool (char const *name, bool value) |
| void | data_set_value_float16 (char const *name, float value) |
| void | init_bool_from_configuration (bool *var, char const *name, bool const default_value) |
| void | init_double_from_configuration (double *var, char const *name, double const default_value) |
| void | init_float_from_configuration (float *var, char const *name, float const default_value) |
| void | init_int32_from_configuration (int32_t *var, char const *name, int32_t const default_value) |
| void | init_uint32_from_configuration (uint32_t *var, char const *name, uint32_t const default_value) |
| void | init_int16_from_configuration (int16_t *var, char const *name, int16_t const default_value) |
| void | init_uint16_from_configuration (uint16_t *var, char const *name, uint16_t const default_value) |
| void | init_int8_from_configuration (int8_t *var, char const *name, int8_t const default_value) |
| void | init_uint8_from_configuration (uint8_t *var, char const *name, uint8_t const default_value) |
| void | init_float_array_from_configuration (float *var, char const *name, size_t const size) |
| void | init_double_array_from_configuration (double *var, char const *name, size_t const size) |
| void | init_string_from_configuration (char *var, char const *name, size_t const size) |
Variables | |
| Messagefifo | my_mes_fifo |
| Messagefifo * | my_mes_fifo_p |
| #define get_infrared_emitter_dir | ( | dir, | |
| emitting_power_list ) |
| #define init_array_from_configuration | ( | a | ) |
| #define init_from_configuration | ( | x | ) |
| #define IR_RX_COUNT 4 |
| #define main robot_main |
| #define MAX_NUMBER_OF_WORD 20 |
| #define MAX_PAYLOAD_SIZE_BYTES 382 |
| #define NUMEL 20 |
| #define pogobot_infrared_emitter_back_mask ( 1 << 16 ) |
| #define pogobot_infrared_emitter_front_mask ( 1 << 0 ) |
| #define pogobot_infrared_emitter_left_mask ( 1 << 24 ) |
| #define pogobot_infrared_emitter_mask_byindex | ( | index | ) |
| #define pogobot_infrared_emitter_power_max 3 |
| #define pogobot_infrared_emitter_power_null 0 |
| #define pogobot_infrared_emitter_power_oneThird 1 |
| #define pogobot_infrared_emitter_power_twoThird 2 |
| #define pogobot_infrared_emitter_right_mask ( 1 << 8 ) |
| #define pogobot_infrared_emitter_width_bits 2 |
| #define pogobot_infrared_emitting_power_list | ( | front, | |
| right, | |||
| back, | |||
| left ) |
| #define printf pogosim_printf |
| #define putchar pogosim_putchar |
| #define SIMULATOR |
| typedef union emitting_power_list_t emitting_power_list_t |
| typedef struct message_header_t message_header_t |
The parameters that begin with "_" are not completed by the user
| typedef struct message_short_header_t message_short_header_t |
| typedef struct message_t message_t |
| typedef struct short_message_t short_message_t |
| typedef struct time_reference_t time_reference_t |
| anonymous enum |
| enum ir_direction |
| enum ir_type_message |
| Enumerator | |
|---|---|
| ir_t_cmd | |
| ir_t_flash | |
| ir_t_short | |
| ir_t_user | |
| enum motor_id |
| enum motor_range |
| enum photosensor_id |
| void data_add_column_bool | ( | char const * | name | ) |
| void data_add_column_double | ( | char const * | name | ) |
| void data_add_column_float16 | ( | char const * | name | ) |
| void data_add_column_int16 | ( | char const * | name | ) |
| void data_add_column_int32 | ( | char const * | name | ) |
| void data_add_column_int64 | ( | char const * | name | ) |
| void data_add_column_int8 | ( | char const * | name | ) |
| void data_add_column_string | ( | char const * | name | ) |
| void data_set_value_bool | ( | char const * | name, |
| bool | value ) |
| void data_set_value_double | ( | char const * | name, |
| double | value ) |
| void data_set_value_float16 | ( | char const * | name, |
| float | value ) |
| void data_set_value_int16 | ( | char const * | name, |
| int16_t | value ) |
| void data_set_value_int32 | ( | char const * | name, |
| int32_t | value ) |
| void data_set_value_int64 | ( | char const * | name, |
| int64_t | value ) |
| void data_set_value_int8 | ( | char const * | name, |
| int8_t | value ) |
| void data_set_value_string | ( | char const * | name, |
| char const * | value ) |
| void disable_data_export | ( | void | ) |
| void enable_data_export | ( | void | ) |
| FifoBuffer_typedef | ( | message_t | , |
| Messagefifo | ) |
| uint32_t get_nb_robots | ( | void | ) |
| void init_bool_from_configuration | ( | bool * | var, |
| char const * | name, | ||
| bool const | default_value ) |
| void init_double_array_from_configuration | ( | double * | var, |
| char const * | name, | ||
| size_t const | size ) |
| void init_double_from_configuration | ( | double * | var, |
| char const * | name, | ||
| double const | default_value ) |
| void init_float_array_from_configuration | ( | float * | var, |
| char const * | name, | ||
| size_t const | size ) |
| void init_float_from_configuration | ( | float * | var, |
| char const * | name, | ||
| float const | default_value ) |
| void init_int16_from_configuration | ( | int16_t * | var, |
| char const * | name, | ||
| int16_t const | default_value ) |
| void init_int32_from_configuration | ( | int32_t * | var, |
| char const * | name, | ||
| int32_t const | default_value ) |
| void init_int8_from_configuration | ( | int8_t * | var, |
| char const * | name, | ||
| int8_t const | default_value ) |
| void init_string_from_configuration | ( | char * | var, |
| char const * | name, | ||
| size_t const | size ) |
| void init_uint16_from_configuration | ( | uint16_t * | var, |
| char const * | name, | ||
| uint16_t const | default_value ) |
| void init_uint32_from_configuration | ( | uint32_t * | var, |
| char const * | name, | ||
| uint32_t const | default_value ) |
| void init_uint8_from_configuration | ( | uint8_t * | var, |
| char const * | name, | ||
| uint8_t const | default_value ) |
| void msleep | ( | int | milliseconds | ) |
| void pli_timer_sleep_stopwatch_init | ( | void | ) |
This is a simple timer implementation based on the available hardware timer.
The benefit is that the only hardware timer we have is configured only once, and all software that depend on it just works without conflict.
The drawback is that we can't use the interrupt of the hardware timer, if available.
To keep the implementation simple, we only rely on the 32bit timer0 counter. This limit the timespan to 2^31/CLOCKRATE, which is 107 seconds with a 20MHz system clock. We can extent the implementation by maintaining a rollover count in some function that we promise to call often enough, add a rollover count in time_reference_t, and extend computations accordingly.
Sample code:
One time interval, measuring duration, think "get elapsed microseconds".
time_reference_t mystopwatch; pogobot_stopwatch_reset( &mystopwatch ); my long_computation( arguments ); uint32_t microseconds = pogobot_stopwatch_get_elapsed_microseconds( &mystopwatch ); printf( "Duration: %u microseconds", milliseconds );
Series of events, measuring duration of each, think "stopwatch lap".
time_reference_t mystopwatch; pogobot_stopwatch_reset( &mystopwatch ); while ( 1 ) { wait_for_some_external_event(); uint32_t microseconds = pogobot_stopwatch_lap( &mystopwatch ); printf( "Time since previous event: %u microseconds", milliseconds ); }
You want your code to periodically do something.
time_reference_t mytimer; uint32_t period_microseconds = 250000; pogobot_timer_init( &mytimer, period_microseconds ); while (1) { wait_for_some_external_event(); if (pogobot_timer_has_expired()) { pogobot_timer_offset_origin_microseconds( &mytimer, period_microseconds ); react_do_something(); } } (pli_timer_sleep_stopwatch_init) Initialise the timer structure (already made inside pogobot_init)
| int16_t pogobot_battery_voltage_read | ( | void | ) |
| uint16_t pogobot_helper_getid | ( | void | ) |
| int16_t pogobot_helper_getRandSeed | ( | void | ) |
| void pogobot_helper_print_version | ( | void | ) |
| void pogobot_imu_read | ( | float * | acc, |
| float * | gyro ) |
| float pogobot_imu_readTemp | ( | void | ) |
| void pogobot_infrared_clear_message_queue | ( | void | ) |
| void pogobot_infrared_get_receiver_error_counter | ( | slip_error_counter_s * | error_counter, |
| uint8_t | ir_index ) |
(pogobot_infrared_get_receiver_error_counter) Get the receiver error counter value
| void pogobot_infrared_ll_init | ( | void | ) |
| int pogobot_infrared_message_available | ( | void | ) |
| void pogobot_infrared_recover_next_message | ( | message_t * | mes | ) |
(pogobot_infrared_recover_next_message) Recover the next message inside the message queue
| void pogobot_infrared_reset_receiver_error_counter | ( | void | ) |
| uint32_t pogobot_infrared_sendLongMessage_omniGen | ( | uint8_t * | message, |
| uint16_t | message_size ) |
(pogobot_infrared_sendLongMessage_omniGen) Send the same message in all direction at defined power Use pogobot_infrared_sendRawLongMessage Their no infrared sender ID
| uint32_t pogobot_infrared_sendLongMessage_omniSpe | ( | uint8_t * | message, |
| uint16_t | message_size ) |
(pogobot_infrared_sendLongMessage_omniSpe) Send successively the same message with the origin infrared ID on each Infrared It is 4 times slower that without ID Use pogobot_infrared_sendRawLongMessage
| uint32_t pogobot_infrared_sendLongMessage_uniSpe | ( | ir_direction | dir, |
| uint8_t * | message, | ||
| uint16_t | message_size ) |
(pogobot_infrared_sendLongMessage_uniSpe) Send a message in only direction at defined power Use pogobot_infrared_sendRawLongMessage
| uint32_t pogobot_infrared_sendRawLongMessage | ( | message_t *const | message | ) |
(pogobot_infrared_sendRawLongMessage) Prepare and send one packet, with the specified emitters and powers, to the recipient, containing the specified message.
| uint32_t pogobot_infrared_sendRawShortMessage | ( | ir_direction | dir, |
| short_message_t *const | message ) |
(pogobot_infrared_sendRawShortMessage) Prepare and send one packet, with a short header containing the specified message.
| uint32_t pogobot_infrared_sendShortMessage_omni | ( | uint8_t * | message, |
| uint16_t | message_size ) |
| uint32_t pogobot_infrared_sendShortMessage_uni | ( | ir_direction | dir, |
| uint8_t * | message, | ||
| uint16_t | message_size ) |
(pogobot_infrared_sendShortMessage_uni) Send a short header message in only direction at defined power Use pogobot_infrared_sendRawShortMessage
| void pogobot_infrared_set_power | ( | uint8_t | power | ) |
| void pogobot_infrared_update | ( | void | ) |
| void pogobot_init | ( | void | ) |
| void pogobot_led_setColor | ( | const uint8_t | r, |
| const uint8_t | g, | ||
| const uint8_t | b ) |
| void pogobot_led_setColors | ( | const uint8_t | r, |
| const uint8_t | g, | ||
| const uint8_t | b, | ||
| uint8_t | id ) |
(pogobot_led_setColors) Set the value of red, green and blue of the led with the number (ID) in static mode each value goes from 0 to 255 to determine the intensity. (only available with a belly with multiple LEDs)
| uint32_t pogobot_motor_dir_current_status | ( | void | ) |
| int8_t pogobot_motor_dir_mem_get | ( | uint8_t * | p_directions | ) |
| int8_t pogobot_motor_dir_mem_set | ( | uint8_t * | p_directions | ) |
| void pogobot_motor_dir_set | ( | motor_id | motor, |
| uint8_t | value ) |
| uint8_t pogobot_motor_power_mem_get | ( | uint16_t * | p_powers | ) |
| uint8_t pogobot_motor_power_mem_set | ( | uint16_t * | p_powers | ) |
| void pogobot_motor_power_set | ( | motor_id | motor, |
| uint16_t | value ) |
| void pogobot_motor_set | ( | motor_id | motor, |
| uint16_t | value ) |
| int16_t pogobot_photosensors_read | ( | uint8_t | sensor_number | ) |
| int32_t pogobot_stopwatch_get_elapsed_microseconds | ( | time_reference_t * | stopwatch | ) |
(pogobot_stopwatch_get_elapsed_microseconds) provides the current number of elapsed microseconds without otherwise interfering with the stopwatch state.
Returns the number of microseconds elapsed on 32 bits (which may be negative if you offset the origin to the future)
| int32_t pogobot_stopwatch_lap | ( | time_reference_t * | stopwatch | ) |
(pogobot_stopwatch_lap) measures time elapsed from origin and offsets so that origin is zero at this point in time.
Returns the number of microseconds elapsed on 32 bits (which may be negative if you offset the origin to the future)
| void pogobot_stopwatch_offset_origin_microseconds | ( | time_reference_t * | stopwatch, |
| int32_t | microseconds_offset ) |
(pogobot_stopwatch_offset_origin_microseconds) offsets the origin of the stopwatch by the specified number of microseconds.
| void pogobot_stopwatch_reset | ( | time_reference_t * | stopwatch | ) |
(pogobot_stopwatch_reset) reset a time_reference structure. To use a time_reference_t as a stopwatch you must reset it using pogobot_stopwatch_reset()
| int32_t pogobot_timer_get_remaining_microseconds | ( | time_reference_t * | timer | ) |
(pogobot_timer_get_remaining_microseconds) provides the current of microseconds until the timer has expired, without otherwise interfering with the timer state.
Returns the number of microseconds elapsed on 32 bits. The result is a signed number, positive when the timer has not expired yet, negative when the timer has expired.
| bool pogobot_timer_has_expired | ( | time_reference_t * | timer | ) |
(pogobot_timer_has_expired) Returns true when the timer has expired, false when the timer has not expired yet.
Returns a bool depending on the status (True: if expired, False: if not expired)
| void pogobot_timer_init | ( | time_reference_t * | timer, |
| int32_t | microseconds_to_go ) |
(pogobot_timer_init) set a timer that will expire in the defined number of microseconds in the future.
| void pogobot_timer_offset_origin_microseconds | ( | time_reference_t * | timer, |
| int32_t | microseconds_offset ) |
(pogobot_timer_offset_origin_microseconds) offsets the origin of the timer by the specified number of microseconds.
| void pogobot_timer_wait_for_expiry | ( | time_reference_t * | timer | ) |
(pogobot_timer_wait_for_expiry) waits until the timer has expired.
| void pogosim_printf | ( | const char * | format, |
| ... ) |
| int pogosim_putchar | ( | int | ch | ) |
| void stop_simulation | ( | void | ) |
(stop_simulation) Stops the simulation
|
extern |
|
extern |