Files | |
| file | apix.h |
Device Registration | |
| enum | v5_device_e { E_DEVICE_NONE = 0 , E_DEVICE_MOTOR = 2 , E_DEVICE_ROTATION = 4 , E_DEVICE_IMU = 6 , E_DEVICE_DISTANCE = 7 , E_DEVICE_RADIO = 8 , E_DEVICE_VISION = 11 , E_DEVICE_ADI = 12 , E_DEVICE_OPTICAL = 16 , E_DEVICE_GPS = 20 , E_DEVICE_AIVISION = 29 , E_DEVICE_SERIAL = 129 , __attribute__ =((deprecated("use E_DEVICE_SERIAL instead"))) = E_DEVICE_SERIAL , E_DEVICE_UNDEFINED = 255 } |
| List of possible v5 devices. More... | |
| typedef enum v5_device_e | v5_device_e_t |
| int | registry_bind_port (uint8_t port, v5_device_e_t device_type) |
| int | registry_unbind_port (uint8_t port) |
| v5_device_e_t | registry_get_bound_type (uint8_t port) |
| v5_device_e_t | registry_get_plugged_type (uint8_t port) |
RTOS Facilities | |
| typedef void * | queue_t |
| typedef void * | sem_t |
| bool | task_abort_delay (task_t task) |
| void | task_notify_when_deleting (task_t target_task, task_t task_to_notify, uint32_t value, notify_action_e_t notify_action) |
| task_t | mutex_get_owner (mutex_t mutex) |
| sem_t | sem_create (uint32_t max_count, uint32_t init_count) |
| void | sem_delete (sem_t sem) |
| sem_t | sem_binary_create (void) |
| bool | sem_wait (sem_t sem, uint32_t timeout) |
| bool | sem_post (sem_t sem) |
| uint32_t | sem_get_count (sem_t sem) |
| queue_t | queue_create (uint32_t length, uint32_t item_size) |
| bool | queue_append (queue_t queue, const void *item, uint32_t timeout) |
| bool | queue_peek (queue_t queue, void *const buffer, uint32_t timeout) |
| bool | queue_recv (queue_t queue, void *const buffer, uint32_t timeout) |
| uint32_t | queue_get_waiting (const queue_t queue) |
| uint32_t | queue_get_available (const queue_t queue) |
| void | queue_delete (queue_t queue) |
| void | queue_reset (queue_t queue) |
Startup options | |
| void | enable_banner (bool enabled) |
| #define | PRE_PROS_INIT_PRIORITY 101 |
| #define | ENABLE_BANNER(enabled) |
Filesystem | |
| int32_t | fdctl (int file, const uint32_t action, void *const extra_arg) |
| int32_t | motor_set_reversed (int8_t port, const bool reverse) |
| int32_t | motor_is_reversed (int8_t port) |
| #define | SERCTL_ACTIVATE 10 |
| #define | SERCTL_DEACTIVATE 11 |
| #define | SERCTL_BLKWRITE 12 |
| #define | SERCTL_NOBLKWRITE 13 |
| #define | SERCTL_ENABLE_COBS 14 |
| #define | SERCTL_DISABLE_COBS 15 |
| #define | DEVCTL_FIONREAD 16 |
| #define | DEVCTL_FIONWRITE 18 |
| #define | DEVCTL_SET_BAUDRATE 17 |
| #define DEVCTL_FIONREAD 16 |
Action macro to check if there is data available from the Generic Serial Device
| #define DEVCTL_FIONWRITE 18 |
Action macro to check if there is space available in the Generic Serial Device's output buffer
| #define DEVCTL_SET_BAUDRATE 17 |
Action macro to set the Generic Serial Device's baudrate.
The extra argument is the baudrate.
| #define ENABLE_BANNER | ( | enabled | ) |
Enable/disable the PROS banner printed to the serial stream.
| enable | Whether the banner should be enabled or disabled. |
| #define PRE_PROS_INIT_PRIORITY 101 |
This priority value, when used with attribute((constructor( ))), is guaranteed to run before PROS initializes.
| #define SERCTL_ACTIVATE 10 |
Action macro to pass into serctl or fdctl that activates the stream identifier.
When used with serctl, the extra argument must be the little endian representation of the stream identifier (e.g. "sout" -> 0x74756f73)
| #define SERCTL_BLKWRITE 12 |
Action macro to pass into fdctl that enables blocking writes for the file
The extra argument is not used with this action, provide any value (e.g. NULL) instead
| #define SERCTL_DEACTIVATE 11 |
Action macro to pass into serctl or fdctl that deactivates the stream identifier.
When used with serctl, the extra argument must be the little endian representation of the stream identifier (e.g. "sout" -> 0x74756f73)
| #define SERCTL_DISABLE_COBS 15 |
Action macro to pass into serctl that disables advanced stream multiplexing capabilities
The extra argument is not used with this action, provide any value (e.g. NULL) instead
| #define SERCTL_ENABLE_COBS 14 |
Action macro to pass into serctl that enables advanced stream multiplexing capabilities
The extra argument is not used with this action, provide any value (e.g. NULL) instead
| #define SERCTL_NOBLKWRITE 13 |
Action macro to pass into fdctl that makes writes non-blocking for the file
The extra argument is not used with this action, provide any value (e.g. NULL) instead
| enum v5_device_e |
List of possible v5 devices.
This list contains all current V5 Devices, and mirrors V5_DeviceType from the api.
| void enable_banner | ( | bool | enabled | ) |
Enable/disable the PROS banner printed to the serial stream.
| enable | Whether the banner should be enabled or disabled. |
| int32_t fdctl | ( | int | file, |
| const uint32_t | action, | ||
| void *const | extra_arg ) |
Control settings of the serial driver.
| action | An action to perform on the serial driver. See the SERCTL_* macros for details on the different actions. |
| extra_arg | An argument to pass in based on the action |
Example:
| int32_t motor_is_reversed | ( | int8_t | port | ) |
Gets the operation direction of the motor as set by the user.
This function uses the following values of errno when an error state is reached: ENXIO - The given value is not within the range of V5 ports (1-21). ENODEV - The port cannot be configured as a motor
| port | The V5 port number from 1-21 |
Example
| int32_t motor_set_reversed | ( | int8_t | port, |
| const bool | reverse ) |
Sets the reverse flag for the motor.
This will invert its movements and the values returned for its position.
This function uses the following values of errno when an error state is reached: ENXIO - The given value is not within the range of V5 ports (1-21). ENODEV - The port cannot be configured as a motor
| port | The V5 port number from 1-21 |
| reverse | True reverses the motor, false is default |
Example
Returns a handle to the current owner of a mutex.
| mutex | A mutex handle |
Example:
| bool queue_append | ( | queue_t | queue, |
| const void * | item, | ||
| uint32_t | timeout ) |
Posts an item to the front of a queue. The item is queued by copy, not by reference.
| queue | The queue handle |
| item | A pointer to the item that will be placed on the queue. |
| timeout | Time to wait for space to become available. A timeout of 0 can be used to attempt to post without blocking. TIMEOUT_MAX can be used to block indefinitely. |
Example:
| queue_t queue_create | ( | uint32_t | length, |
| uint32_t | item_size ) |
Creates a queue.
| length | The maximum number of items that the queue can contain. |
| item_size | The number of bytes each item in the queue will require. |
Example:
| void queue_delete | ( | queue_t | queue | ) |
Delete a queue.
| queue | Queue handle to delete |
Example:
| uint32_t queue_get_available | ( | const queue_t | queue | ) |
Return the number of spaces left in a queue.
| queue | The queue handle. |
Example:
| uint32_t queue_get_waiting | ( | const queue_t | queue | ) |
Return the number of messages stored in a queue.
| queue | The queue handle. |
Example:
| bool queue_peek | ( | queue_t | queue, |
| void *const | buffer, | ||
| uint32_t | timeout ) |
Receive an item from a queue without removing the item from the queue.
| queue | The queue handle |
| buffer | Pointer to a buffer to which the received item will be copied |
| timeout | The maximum amount of time the task should block waiting for an item to receive should the queue be empty at the time of the call. TIMEOUT_MAX can be used to block indefinitely. |
Example:
| bool queue_recv | ( | queue_t | queue, |
| void *const | buffer, | ||
| uint32_t | timeout ) |
Receive an item from the queue.
| queue | The queue handle |
| buffer | Pointer to a buffer to which the received item will be copied |
| timeout | The maximum amount of time the task should block waiting for an item to receive should the queue be empty at the time of the call. queue_recv() will return immediately if timeout is zero and the queue is empty. |
Example:
| void queue_reset | ( | queue_t | queue | ) |
Resets a queue to an empty state
| queue | Queue handle to reset |
Example:
| int registry_bind_port | ( | uint8_t | port, |
| v5_device_e_t | device_type ) |
Registers a device in the given zero-indexed port
Registers a device of the given type in the given port into the registry, if that type of device is detected to be plugged in to that port.
This function uses the following values of errno when an error state is reached: ENXIO - The given value is not within the range of V5 ports (0-20), or a a different device than specified is plugged in. EADDRINUSE - The port is already registered to another device.
| port | The port number to register the device |
| device | The type of device to register |
Example:
| v5_device_e_t registry_get_bound_type | ( | uint8_t | port | ) |
Returns the type of device registered to the zero-indexed port.
This function uses the following values of errno when an error state is reached: ENXIO - The given value is not within the range of V5 ports (0-20).
| port | The V5 port number from 0-20 |
Example:
| v5_device_e_t registry_get_plugged_type | ( | uint8_t | port | ) |
Returns the type of the device plugged into the zero-indexed port.
This function uses the following values of errno when an error state is reached: ENXIO - The given value is not within the range of V5 ports (0-20).
| port | The V5 port number from 0-20 |
Example:
| int registry_unbind_port | ( | uint8_t | port | ) |
Deregisters a devices from the given zero-indexed port
Removes the device registed in the given port, if there is one.
This function uses the following values of errno when an error state is reached: ENXIO - The given value is not within the range of V5 ports (0-20).
| port | The port number to deregister |
Example:
| sem_t sem_binary_create | ( | void | ) |
Creates a binary semaphore.
Example:
| sem_t sem_create | ( | uint32_t | max_count, |
| uint32_t | init_count ) |
Creates a counting sempahore.
| max_count | The maximum count value that can be reached. |
| init_count | The initial count value assigned to the new semaphore. |
Example:
| void sem_delete | ( | sem_t | sem | ) |
Deletes a semaphore (or binary semaphore)
| sem | Semaphore to delete |
Example:
| uint32_t sem_get_count | ( | sem_t | sem | ) |
Returns the current value of the semaphore.
| sem | A semaphore handle |
Example of sem_get_count:
| bool sem_post | ( | sem_t | sem | ) |
Increments a semaphore's value.
| sem | Semaphore to post |
Example:
| bool sem_wait | ( | sem_t | sem, |
| uint32_t | timeout ) |
Waits for the semaphore's value to be greater than 0. If the value is already greater than 0, this function immediately returns.
| sem | Semaphore to wait on |
| timeout | Time to wait before the semaphore's becomes available. A timeout of 0 can be used to poll the sempahore. TIMEOUT_MAX can be used to block indefinitely. |
Example:
| bool task_abort_delay | ( | task_t | task | ) |
Unblocks a task in the Blocked state (e.g. waiting for a delay, on a semaphore, etc.).
| task | The task to unblock |
Example:
| void task_notify_when_deleting | ( | task_t | target_task, |
| task_t | task_to_notify, | ||
| uint32_t | value, | ||
| notify_action_e_t | notify_action ) |
Notify a task when a target task is being deleted.
| target_task | The task being watched for deletion |
| task_to_notify | The task to notify when target_task is deleted |
| value | The value to supply to task_notify_ext |
| notify_action | The action to supply to task_notify_ext |
Example: