16#include BOARD_DEF_PATH
26static bool rf_sw_external;
27static bool rf_sw_power_on =
true;
29static void rf_switch_apply(
void);
32static void rf_switch_print_status(shell_output_func output);
33static PT_THREAD(cmd_rf_switch(
struct pt *pt, shell_output_func output,
char *args));
34PROCESS(xiao_nrf54l15_rf_switch_shell_process,
"XIAO RF switch shell");
36static const struct shell_command_t rf_switch_commands[] = {
40 "'> rf-sw': status | ceramic | external | power [0|1|off|on]"
45static struct shell_command_set_t rf_switch_shell_set = {
47 .commands = rf_switch_commands,
55 NRF_GPIO_PIN_MAP(XIAO_NRF54L15_RF_SW_SEL_PORT, XIAO_NRF54L15_RF_SW_SEL_PIN);
57 NRF_GPIO_PIN_MAP(XIAO_NRF54L15_RF_SW_PWR_PORT, XIAO_NRF54L15_RF_SW_PWR_PIN);
59 nrf_gpio_cfg_output(rf_sw_sel);
60 nrf_gpio_cfg_output(rf_sw_pwr);
63 nrf_gpio_pin_set(rf_sw_sel);
65 nrf_gpio_pin_clear(rf_sw_sel);
69 nrf_gpio_pin_set(rf_sw_pwr);
71 nrf_gpio_pin_clear(rf_sw_pwr);
76platform_init_board(
void)
80 rf_sw_external =
false;
81 rf_sw_power_on =
true;
86platform_init_board_stage_two(
void)
95rf_switch_print_status(shell_output_func output)
97 const char *path = rf_sw_external ?
"external" :
"ceramic";
98 const char *power = rf_sw_power_on ?
"on" :
"off";
100 NRF_GPIO_PIN_MAP(XIAO_NRF54L15_RF_SW_SEL_PORT, XIAO_NRF54L15_RF_SW_SEL_PIN);
102 NRF_GPIO_PIN_MAP(XIAO_NRF54L15_RF_SW_PWR_PORT, XIAO_NRF54L15_RF_SW_PWR_PIN);
105 "RF switch: path=%s power=%s raw(sel=%u pwr=%u)\n",
107 (
unsigned)nrf_gpio_pin_read(rf_sw_sel),
108 (
unsigned)nrf_gpio_pin_read(rf_sw_pwr));
111static PT_THREAD(cmd_rf_switch(
struct pt *pt, shell_output_func output,
char *args))
117 SHELL_ARGS_INIT(args, next_args);
118 SHELL_ARGS_NEXT(args, next_args);
120 if(args == NULL || !strcmp(args,
"status")) {
121 rf_switch_print_status(output);
125 if(!strcmp(args,
"ceramic")) {
126 rf_sw_external =
false;
127 rf_sw_power_on =
true;
129 rf_switch_print_status(output);
133 if(!strcmp(args,
"external")) {
134 rf_sw_external =
true;
135 rf_sw_power_on =
true;
137 rf_switch_print_status(output);
141 if(!strcmp(args,
"power")) {
142 SHELL_ARGS_NEXT(args, next_args);
144 rf_switch_print_status(output);
148 if(!strcmp(args,
"1") || !strcmp(args,
"on")) {
149 rf_sw_power_on =
true;
151 rf_switch_print_status(output);
155 if(!strcmp(args,
"0") || !strcmp(args,
"off")) {
156 rf_sw_power_on =
false;
158 rf_switch_print_status(output);
162 SHELL_OUTPUT(output,
"Usage: rf-sw power [0|1|off|on]\n");
166 SHELL_OUTPUT(output,
"Usage: rf-sw status|ceramic|external|power [0|1|off|on]\n");
172 static struct etimer register_timer;
179 shell_command_set_register(&rf_switch_shell_set);
static bool etimer_expired(struct etimer *et)
Check if an event timer has expired.
void etimer_set(struct etimer *et, clock_time_t interval)
Set an event timer.
#define PROCESS(name, strname)
Declare a process.
#define PROCESS_BEGIN()
Define the beginning of a process.
#define PROCESS_WAIT_EVENT_UNTIL(c)
Wait for an event to be posted to the process, with an extra condition.
#define PROCESS_END()
Define the end of a process.
void process_start(struct process *p, process_data_t data)
Start a process.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PT_BEGIN(pt)
Declare the start of a protothread inside the C function implementing the protothread.
#define PT_THREAD(name_args)
Declaration of a protothread.
#define PT_END(pt)
Declare the end of a protothread.
#define PT_EXIT(pt)
Exit the protothread.
Main header file for the Contiki shell.
Main header file for the Contiki shell.