3#ifndef PRINTLINES_ALLOWED
4#define PRINTLINES_ALLOWED 0
7static const char *FNAME =
"kest_fpga_comms.c";
9#define KEST_FPGA_MSG_TYPE_BATCH 0
10#define KEST_FPGA_MSG_TYPE_PROGRAM_BATCH 1
11#define KEST_FPGA_MSG_TYPE_SET_INPUT_GAIN 2
12#define KEST_FPGA_MSG_TYPE_SET_OUTPUT_GAIN 3
13#define KEST_FPGA_MSG_TYPE_COMMAND 4
15#define FPGA_BOOT_MS 2000
27static QueueHandle_t fpga_msg_queue;
28static int initialised = 0;
30#define PROGRAM_RETRIES 3
44 KEST_PRINTF(
"Starting FPGA comms. FPGA reports status code %d\n",
byte);
49 int program_check_ms = 5;
50 int program_check_ticks = 5 / portTICK_PERIOD_MS;
51 int program_check_delay = (program_check_ticks == 0) ? 1 : program_check_ticks;
58 xQueueReceive(fpga_msg_queue, &msg, portMAX_DELAY);
63 #ifdef PRINT_TRANSFER_BATCHES
66 #ifndef KEST_FPGA_SIMULATED
70 vTaskDelay(program_check_delay);
75 KEST_PRINTF(
"FPGA responded with code %d after programming. Retrying...\n",
byte);
89 #ifdef PRINT_TRANSFER_BATCHES
105 #ifdef PRINT_COMMANDS
118 while (!initialised);
120 if (xQueueSend(fpga_msg_queue, (
void*)&msg, (TickType_t)1) != pdPASS)
134 int ret_val = kest_fpga_queue_msg(msg);
147 int ret_val = kest_fpga_queue_msg(msg);
159 return kest_fpga_queue_msg(msg);
169 return kest_fpga_queue_msg(msg);
179 return kest_fpga_queue_msg(msg);
#define ERR_QUEUE_SEND_FAILED
int kest_fpga_queue_input_gain_set(float gain_db)
#define KEST_FPGA_MSG_TYPE_SET_INPUT_GAIN
#define KEST_FPGA_MSG_TYPE_PROGRAM_BATCH
int kest_fpga_queue_transfer_batch(kest_fpga_transfer_batch batch)
int kest_fpga_queue_register_commit()
#define KEST_FPGA_MSG_TYPE_COMMAND
#define KEST_FPGA_MSG_TYPE_BATCH
void kest_fpga_comms_task(void *param)
int kest_fpga_queue_program_batch(kest_fpga_transfer_batch batch)
int kest_fpga_queue_output_gain_set(float gain_db)
#define KEST_FPGA_MSG_TYPE_SET_OUTPUT_GAIN
int kest_fpga_batch_print(kest_fpga_transfer_batch seq)
void kest_fpga_set_input_gain(float gain_db)
char * kest_fpga_command_to_string(int command)
int kest_fpga_send_byte(uint8_t byte)
void kest_fpga_set_output_gain(float gain_db)
void kest_free_fpga_transfer_batch(kest_fpga_transfer_batch batch)
uint8_t kest_fpga_read_byte()
int kest_fpga_transfer_batch_send(kest_fpga_transfer_batch batch)
#define COMMAND_COMMIT_REG_UPDATES
kest_fpga_transfer_batch batch
union kest_fpga_msg::@213017006217226057222213157222053127064260276366 data