summaryrefslogtreecommitdiff
path: root/source/com_task.c
diff options
context:
space:
mode:
authorDominik Sliwa <dominik.sliwa@toradex.com>2017-04-05 14:00:11 +0200
committerDominik Sliwa <dominik.sliwa@toradex.com>2017-04-05 14:03:38 +0200
commitb3bc06bef795fdc57254729c74c04e2732a6092d (patch)
tree1582cb5edd1f6ebcdfed12d3bc43c62364fd2751 /source/com_task.c
parent23a27e51577ded4d070794b864585829c69cdc56 (diff)
Apalis_TK1_K20: CAN support and version change
Includes CAN support and fw version bump to 0.9 Signed-off-by: Dominik Sliwa <dominik.sliwa@toradex.com>
Diffstat (limited to 'source/com_task.c')
-rw-r--r--source/com_task.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/source/com_task.c b/source/com_task.c
index 348c3e1..457066c 100644
--- a/source/com_task.c
+++ b/source/com_task.c
@@ -1,15 +1,15 @@
#include "com_task.h"
+#include "can_task.h"
#include "gpio_ext.h"
#include "adc_task.h"
/* Put FW version at known address in binary. Make it 32-bit to have room for the future*/
const uint32_t __attribute__((section(".FwVersion"))) fw_version = APALIS_TK1_K20_FW_VER;
-#define MAX_TRANSFER_SIZE 32U
static dspi_slave_handle_t spi_handle;
-static uint8_t slaveRxData[MAX_TRANSFER_SIZE] = {0U};
-static uint8_t slaveTxData[MAX_TRANSFER_SIZE] = {0U};
+static uint8_t slaveRxData[APALIS_TK1_K20_MAX_BULK] = {0U};
+static uint8_t slaveTxData[APALIS_TK1_K20_MAX_BULK] = {0U};
void generate_irq(uint8_t irq) {
gen_regs.irq = gen_regs.irq | BIT(irq);
@@ -67,7 +67,7 @@ void set_irq_reg(uint8_t value)
}
-int inline general_registers(uint8_t *rx_buf, uint8_t * tx_buf) {
+inline int general_registers(uint8_t *rx_buf, uint8_t * tx_buf) {
if (rx_buf[0] == APALIS_TK1_K20_READ_INST) {
switch (rx_buf[1]) {
@@ -173,6 +173,13 @@ void spi_task(void *pvParameters) {
xSemaphoreTake(cb_msg.sem, portMAX_DELAY);
if (slaveRxData[1] <= 0x05) {
ret = general_registers(slaveRxData, &slaveTxData[1]);
+ } else if ((slaveRxData[1] >= APALIS_TK1_K20_CANREG + APALIS_TK1_K20_CAN_DEV_OFFSET(0))
+ && (slaveRxData[1] <= APALIS_TK1_K20_CAN_OUT_FIF0_END + APALIS_TK1_K20_CAN_DEV_OFFSET(0))) {
+ ret = can0_registers(slaveRxData, &slaveTxData[1]);
+
+ } else if ((slaveRxData[1] >= APALIS_TK1_K20_CANREG + APALIS_TK1_K20_CAN_DEV_OFFSET(1))
+ && (slaveRxData[1] <= APALIS_TK1_K20_CAN_OUT_FIF0_END + APALIS_TK1_K20_CAN_DEV_OFFSET(1))) {
+ ret = can1_registers(slaveRxData, &slaveTxData[1]);
#ifdef BOARD_USES_ADC
} else if ((slaveRxData[1] >= APALIS_TK1_K20_ADCREG) && (slaveRxData[1] <= APALIS_TK1_K20_ADC_CH3H)) {
ret = adc_registers(slaveRxData, &slaveTxData[1]);