|
| 1 | +/* |
| 2 | + * || ____ _ __ |
| 3 | + * +------+ / __ )(_) /_______________ _____ ___ |
| 4 | + * | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \ |
| 5 | + * +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/ |
| 6 | + * || || /_____/_/\__/\___/_/ \__,_/ /___/\___/ |
| 7 | + * |
| 8 | + * Crazyflie control firmware |
| 9 | + * |
| 10 | + * Copyright (C) 2024 Bitcraze AB |
| 11 | + * |
| 12 | + * This program is free software: you can redistribute it and/or modify |
| 13 | + * it under the terms of the GNU General Public License as published by |
| 14 | + * the Free Software Foundation, in version 3. |
| 15 | + * |
| 16 | + * This program is distributed in the hope that it will be useful, |
| 17 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | + * GNU General Public License for more details. |
| 20 | + * |
| 21 | + * You should have received a copy of the GNU General Public License |
| 22 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 23 | + * |
| 24 | + * radiotest.c - Use this deck driver to test the radio |
| 25 | + */ |
| 26 | +#define DEBUG_MODULE "RADIOTEST" |
| 27 | + |
| 28 | +#include <stdint.h> |
| 29 | +#include <string.h> |
| 30 | + |
| 31 | +#include "FreeRTOS.h" |
| 32 | +#include "task.h" |
| 33 | + |
| 34 | +#include "stm32fxxx.h" |
| 35 | +#include "config.h" |
| 36 | +#include "debug.h" |
| 37 | +#include "deck.h" |
| 38 | +#include "syslink.h" |
| 39 | +#include "param.h" |
| 40 | + |
| 41 | +//Hardware configuration |
| 42 | +static bool isInit; |
| 43 | +static uint8_t channel = 80; |
| 44 | +static int8_t power = -16; |
| 45 | +static uint8_t contwave = 0; |
| 46 | +static uint8_t old_channel; |
| 47 | +static int8_t old_power; |
| 48 | +static uint8_t old_contwave; |
| 49 | + |
| 50 | +static void radiotestTask(void *param) |
| 51 | +{ |
| 52 | + |
| 53 | + SyslinkPacket slp; |
| 54 | + old_channel = 0; |
| 55 | + old_power = 0; |
| 56 | + old_contwave = contwave; |
| 57 | + |
| 58 | + while (1) |
| 59 | + { |
| 60 | + vTaskDelay(M2T(1000)); |
| 61 | + |
| 62 | + if (contwave != old_contwave) |
| 63 | + { |
| 64 | + slp.type = SYSLINK_RADIO_CONTWAVE; |
| 65 | + slp.length = 1; |
| 66 | + slp.data[0] = contwave; |
| 67 | + syslinkSendPacket(&slp); |
| 68 | + old_contwave = contwave; |
| 69 | + } |
| 70 | + if (channel != old_channel) |
| 71 | + { |
| 72 | + slp.type = SYSLINK_RADIO_CHANNEL; |
| 73 | + slp.length = 1; |
| 74 | + slp.data[0] = channel; |
| 75 | + syslinkSendPacket(&slp); |
| 76 | + old_channel = channel; |
| 77 | + } |
| 78 | + if (power != old_power) |
| 79 | + { |
| 80 | + slp.type = SYSLINK_RADIO_POWER; |
| 81 | + slp.length = 1; |
| 82 | + slp.data[0] = power; |
| 83 | + syslinkSendPacket(&slp); |
| 84 | + old_power = power; |
| 85 | + } |
| 86 | + } |
| 87 | +} |
| 88 | + |
| 89 | + |
| 90 | +static void radiotestInit(DeckInfo *info) |
| 91 | +{ |
| 92 | + if(isInit) |
| 93 | + return; |
| 94 | + |
| 95 | + xTaskCreate(radiotestTask, "RADIOTEST", configMINIMAL_STACK_SIZE, NULL, 1, NULL); |
| 96 | + |
| 97 | + isInit = true; |
| 98 | +} |
| 99 | + |
| 100 | +static bool radiotestTest() |
| 101 | +{ |
| 102 | + bool status = true; |
| 103 | + |
| 104 | + if(!isInit) |
| 105 | + return false; |
| 106 | + |
| 107 | + return status; |
| 108 | +} |
| 109 | + |
| 110 | +static const DeckDriver radiotest_deck = { |
| 111 | + .vid = 0, |
| 112 | + .pid = 0, |
| 113 | + .name = "bcRadioTest", |
| 114 | + |
| 115 | + .init = radiotestInit, |
| 116 | + .test = radiotestTest, |
| 117 | +}; |
| 118 | + |
| 119 | +DECK_DRIVER(radiotest_deck); |
| 120 | + |
| 121 | +PARAM_GROUP_START(radiotest) |
| 122 | +PARAM_ADD(PARAM_UINT8, channel, &channel) |
| 123 | +PARAM_ADD(PARAM_INT8, power, &power) |
| 124 | +PARAM_ADD(PARAM_UINT8, contwave, &contwave) |
| 125 | + |
| 126 | +PARAM_GROUP_STOP(radiotest) |
0 commit comments