ZestCode
 
Loading...
Searching...
No Matches
apix.h
Go to the documentation of this file.
1
24
25#ifndef _PROS_API_EXTENDED_H_
26#define _PROS_API_EXTENDED_H_
27
28#include "api.h"
29#pragma GCC diagnostic push
30#pragma GCC diagnostic ignored "-Wall"
31#pragma GCC diagnostic pop
32
33#ifdef __cplusplus
34namespace pros::c {
35extern "C" {
36#endif
37
41
46
49
50typedef void* queue_t;
51typedef void* sem_t;
52
72
99 task_t target_task,
100 task_t task_to_notify,
101 uint32_t value,
102 notify_action_e_t notify_action
103);
104
145
175sem_t sem_create(uint32_t max_count, uint32_t init_count);
176
212void sem_delete(sem_t sem);
213
238
284bool sem_wait(sem_t sem, uint32_t timeout);
285
314bool sem_post(sem_t sem);
315
340uint32_t sem_get_count(sem_t sem);
341
364queue_t queue_create(uint32_t length, uint32_t item_size);
365
391bool queue_prepend(queue_t queue, const void* item, uint32_t timeout);
392
419bool queue_append(queue_t queue, const void* item, uint32_t timeout);
420
448bool queue_peek(queue_t queue, void* const buffer, uint32_t timeout);
449
479bool queue_recv(queue_t queue, void* const buffer, uint32_t timeout);
480
501uint32_t queue_get_waiting(const queue_t queue);
502
523uint32_t queue_get_available(const queue_t queue);
524
539void queue_delete(queue_t queue);
540
558void queue_reset(queue_t queue);
559
561
564
573typedef enum v5_device_e {
586 E_DEVICE_GENERIC __attribute__((deprecated("use E_DEVICE_SERIAL instead"))) = E_DEVICE_SERIAL,
588} v5_device_e_t;
589
616int registry_bind_port(uint8_t port, v5_device_e_t device_type);
617
640int registry_unbind_port(uint8_t port);
641
663v5_device_e_t registry_get_bound_type(uint8_t port);
664
686v5_device_e_t registry_get_plugged_type(uint8_t port);
687
689
692
703void enable_banner(bool enabled);
704
709#define PRE_PROS_INIT_PRIORITY 101
710
719#ifdef __cplusplus
720 #define ENABLE_BANNER(enabled) \
721 static_assert( \
722 !__builtin_strcmp(__FUNCTION__, "top level"), \
723 "Cannot use ENABLE_BANNER inside a function!" \
724 ); \
725 __attribute__((constructor(PRE_PROS_INIT_PRIORITY))) static void _enable_banner_impl() { \
726 pros::c::enable_banner(enabled); \
727 }
728#else
729 #define ENABLE_BANNER(enabled) \
730 static_assert( \
731 !__builtin_strcmp(__FUNCTION__, "top level"), \
732 "Cannot use ENABLE_BANNER inside a function!" \
733 ); \
734 __attribute__((constructor(PRE_PROS_INIT_PRIORITY))) static void _enable_banner_impl() { \
735 enable_banner(enabled); \
736 }
737#endif
739
742
758int32_t serctl(const uint32_t action, void* const extra_arg);
759
760/*
761 * Control settings of the microSD card driver.
762 *
763 * \param action
764 * An action to perform on the microSD card driver. See the USDCTL_* macros
765 * for details on the different actions.
766 * \param extra_arg
767 * An argument to pass in based on the action
768 */
769// Not yet implemented
770// int32_t usdctl(const uint32_t action, void* const extra_arg);
771
793int32_t fdctl(int file, const uint32_t action, void* const extra_arg);
794
821int32_t motor_set_reversed(int8_t port, const bool reverse);
822
845int32_t motor_is_reversed(int8_t port);
846
855#define SERCTL_ACTIVATE 10
856
865#define SERCTL_DEACTIVATE 11
866
874#define SERCTL_BLKWRITE 12
875
883#define SERCTL_NOBLKWRITE 13
884
893#define SERCTL_ENABLE_COBS 14
894
903#define SERCTL_DISABLE_COBS 15
904
910#define DEVCTL_FIONREAD 16
911
917#define DEVCTL_FIONWRITE 18
918
924#define DEVCTL_SET_BAUDRATE 17
925
927
929
930#ifdef __cplusplus
931}
932}
933#endif
934
935#endif // _PROS_API_EXTENDED_H_
int registry_unbind_port(uint8_t port)
bool task_abort_delay(task_t task)
void queue_delete(queue_t queue)
void sem_delete(sem_t sem)
int32_t motor_set_reversed(int8_t port, const bool reverse)
task_t mutex_get_owner(mutex_t mutex)
sem_t sem_create(uint32_t max_count, uint32_t init_count)
void enable_banner(bool enabled)
bool queue_append(queue_t queue, const void *item, uint32_t timeout)
v5_device_e_t registry_get_plugged_type(uint8_t port)
queue_t queue_create(uint32_t length, uint32_t item_size)
uint32_t sem_get_count(sem_t sem)
int32_t fdctl(int file, const uint32_t action, void *const extra_arg)
sem_t sem_binary_create(void)
int32_t motor_is_reversed(int8_t port)
bool sem_post(sem_t sem)
v5_device_e
List of possible v5 devices.
Definition apix.h:573
uint32_t queue_get_available(const queue_t queue)
bool queue_peek(queue_t queue, void *const buffer, uint32_t timeout)
void task_notify_when_deleting(task_t target_task, task_t task_to_notify, uint32_t value, notify_action_e_t notify_action)
bool queue_recv(queue_t queue, void *const buffer, uint32_t timeout)
v5_device_e_t registry_get_bound_type(uint8_t port)
uint32_t queue_get_waiting(const queue_t queue)
void queue_reset(queue_t queue)
bool sem_wait(sem_t sem, uint32_t timeout)
int registry_bind_port(uint8_t port, v5_device_e_t device_type)
@ E_DEVICE_GPS
A GPS sensor is plugged into the port.
Definition apix.h:583
@ E_DEVICE_VISION
A vision sensor is plugged into the port.
Definition apix.h:580
@ E_DEVICE_IMU
An inertial sensor is plugged into the port.
Definition apix.h:577
@ E_DEVICE_RADIO
A radio is plugged into the port.
Definition apix.h:579
@ E_DEVICE_MOTOR
A motor is plugged into the port.
Definition apix.h:575
@ E_DEVICE_UNDEFINED
The device type is not defined, or is not a valid device.
Definition apix.h:587
@ E_DEVICE_NONE
No device is plugged into the port.
Definition apix.h:574
@ E_DEVICE_SERIAL
A serial device is plugged into the port.
Definition apix.h:585
@ E_DEVICE_ADI
This port is an ADI expander.
Definition apix.h:581
@ E_DEVICE_DISTANCE
A distance sensor is plugged into the port.
Definition apix.h:578
@ E_DEVICE_AIVISION
An AI Vision sensor is plugged into the port.
Definition apix.h:584
@ E_DEVICE_ROTATION
A rotation sensor is plugged into the port.
Definition apix.h:576
@ E_DEVICE_OPTICAL
An optical sensor is plugged into the port.
Definition apix.h:582
void * task_t
Definition rtos.h:100
notify_action_e_t
Definition rtos.h:131
void * mutex_t
Definition rtos.h:184