40 #include <nuttx/config.h> 42 #include <sys/types.h> 47 #include <semaphore.h> 60 #include <nuttx/arch.h> 61 #include <nuttx/clock.h> 63 #include <board_config.h> 66 #define TEST_PPM_PIN (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTE|GPIO_PIN15) 104 for (
int i = 0; i < 20; i++) {
168 void start(
unsigned channels);
171 void set(
unsigned ch,
unsigned value);
183 if (g_test !=
nullptr)
186 errx(1,
"already started");
191 if (g_test ==
nullptr) {
195 if (
OK != g_test->
init()) {
202 if (g_test !=
nullptr) {
207 errx(1,
"test_ppm start failed");
213 if (g_test !=
nullptr) {
219 warnx(
"test_ppm already stopped.");
226 set(
unsigned ch,
unsigned value)
228 if (ch > 18 || ch < 1) {
warnx(
"channel is not valid.");}
230 if (value > 2500 || value < 1) {
warnx(
"value is not valid.");}
233 g_test->
_gaps[ch] = 2500 - value;
243 warnx(
"missing command: try 'start', 'stop', 'set'\n");
256 const char *verb = argv[1];
257 unsigned channels = 7;
262 if (!strcmp(verb,
"start")) {
267 if (!strcmp(verb,
"stop")) {
276 if (!strcmp(verb,
"set")) {
278 errx(1,
"Usage: test_ppm set <channel> <value>");
281 unsigned channel = strtol(argv[2], NULL, 0);
282 unsigned value = strtol(argv[3], NULL, 0);
void stop()
Stop the driver.
static void loops(void *arg)
void(* hrt_callout)(void *arg)
Callout function type.
void usage(const char *reason)
Print the correct usage.
High-resolution timer with callouts and timekeeping.
__EXPORT void hrt_call_after(struct hrt_call *entry, hrt_abstime delay, hrt_callout callout, void *arg)
Call callout(arg) after delay has elapsed.
void start(unsigned channels)
Start the driver.
TEST_PPM(unsigned channels)
void set(unsigned ch, unsigned value)
Definition of commonly used conversions.
Simple error/warning functions, heavily inspired by the BSD functions of the same names...
void usage()
Prints info about the driver argument usage.
__EXPORT int test_ppm_main(int argc, char *argv[])
driver 'main' command
__EXPORT void hrt_cancel(struct hrt_call *entry)
Remove the entry from the callout list.
Performance measuring tools.