From 0820a1d4a6eaf47e414c5077cc8c64d1295ebf3a Mon Sep 17 00:00:00 2001 From: Dominik Sliwa Date: Fri, 4 May 2018 12:10:09 +0200 Subject: build k20 tester fw with TESTER_BUILD Tester build includes: -Disabled CAN, -No debug interface, -Most GPIOs configured as input and accesible from linux driver -Special fw version number (0xFE) Signed-off-by: Dominik Sliwa --- board/pin_mux.c | 13 +++++++++++-- source/apalis-tk1-k20-api.h | 7 +++++-- source/com_task.c | 2 ++ source/gpio_ext.h | 10 +++++++++- source/main.c | 8 ++++++-- utilities/fsl_debug_console.h | 3 +++ 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/board/pin_mux.c b/board/pin_mux.c index f989a8f..12d133c 100644 --- a/board/pin_mux.c +++ b/board/pin_mux.c @@ -56,6 +56,7 @@ void BOARD_InitPins(void) kGPIO_DigitalInput, }; port_pin_config_t od_config; + port_pin_config_t in_config; CLOCK_EnableClock(kCLOCK_PortA); CLOCK_EnableClock(kCLOCK_PortB); @@ -66,7 +67,7 @@ void BOARD_InitPins(void) /* Osc pins */ PORT_SetPinMux(PORTA, 18UL, kPORT_PinDisabledOrAnalog); PORT_SetPinMux(PORTA, 19UL, kPORT_PinDisabledOrAnalog); - +#ifndef TESTER_BUILD /* CAN0 pinmux config */ PORT_SetPinMux(PORTA, 12u, kPORT_MuxAlt2); /* CAN0 TX */ PORT_SetPinMux(PORTA, 13u, kPORT_MuxAlt2); /* CAN0 RX */ @@ -80,6 +81,7 @@ void BOARD_InitPins(void) PORT_SetPinMux(PORTE, 0u, kPORT_MuxAlt3); /* UART1 TX */ PORT_SetPinMux(PORTE, 1u, kPORT_MuxAlt3); /* UART1 RX */ #endif +#endif #ifdef BOARD_USES_ADC /* Resistive Touch panel pinmux config */ @@ -132,8 +134,15 @@ void BOARD_InitPins(void) PORT_SetPinConfig(PORTC, 19u, &od_config); /* PMIC_ONKEY */ /* GPIOs */ + in_config.mux = kPORT_MuxAsGpio; + in_config.openDrainEnable = kPORT_OpenDrainDisable; + in_config.pullSelect = kPORT_PullDown; + in_config.slewRate = kPORT_FastSlewRate; + in_config.passiveFilterEnable = kPORT_PassiveFilterDisable; + in_config.driveStrength = kPORT_LowDriveStrength; + in_config.lockRegister = kPORT_UnlockRegister; for (i = 0; i < sizeof(gpio_list)/sizeof(struct gpio_id); i++){ - PORT_SetPinMux(gpio_list[i].port, gpio_list[i].pin, kPORT_MuxAsGpio); + PORT_SetPinConfig(gpio_list[i].port, gpio_list[i].pin, &in_config); GPIO_PinInit(gpio_list[i].gpio, gpio_list[i].pin, &gpio_in_config); } diff --git a/source/apalis-tk1-k20-api.h b/source/apalis-tk1-k20-api.h index 85bbf9f..35fc88d 100644 --- a/source/apalis-tk1-k20-api.h +++ b/source/apalis-tk1-k20-api.h @@ -48,7 +48,7 @@ #define APALIS_TK1_K20_CAN_DEV_OFFSET(x) (x ? APALIS_TK1_K20_CAN_OFFSET : 0) /* 0x30-0x3F Reserved */ -/* 0x40-0x62 CAN1 registers same layout as CAN0*/ +/* 0x40-0x62 CAN1 registers same layout as CAN0 */ /* 0x63-0x6F Reserved */ /* ADC Registers */ @@ -104,7 +104,11 @@ #define APALIS_TK1_K20_TSC_IRQ 4 #define APALIS_TK1_K20_GPIO_IRQ 5 +#ifndef TESTER_BUILD #define APALIS_TK1_K20_FW_VER 0x10 +#else +#define APALIS_TK1_K20_FW_VER 0xFE +#endif #define FW_MINOR (APALIS_TK1_K20_FW_VER & 0x0F) #define FW_MAJOR ((APALIS_TK1_K20_FW_VER & 0xF0) >> 4) @@ -112,7 +116,6 @@ #define TK1_K20_SENTINEL 0x55 #define TK1_K20_INVAL 0xAA -#define APALIS_TK1_K20_NUMREGS 0x3f #define APALIS_TK1_K20_IRQ_REG_CNT 1 #define APALIS_TK1_K20_IRQ_PER_REG 8 diff --git a/source/com_task.c b/source/com_task.c index 4b73209..cd5af10 100644 --- a/source/com_task.c +++ b/source/com_task.c @@ -202,6 +202,7 @@ void spi_task(void *pvParameters) { if (slaveRxData[0] != APALIS_TK1_K20_READ_INST) { if (slaveRxData[1] <= 0x05) { ret = general_registers(&slaveXfer); +#ifndef TESTER_BUILD } else if ((slaveRxData[1] >= APALIS_TK1_K20_CANREG + APALIS_TK1_K20_CAN_DEV_OFFSET(0)) && (slaveRxData[1] <= APALIS_TK1_K20_CAN_OUT_BUF_END + APALIS_TK1_K20_CAN_DEV_OFFSET(0))) { ret = canx_registers(&slaveXfer, 0); @@ -211,6 +212,7 @@ void spi_task(void *pvParameters) { && (slaveRxData[1] <= APALIS_TK1_K20_CAN_OUT_BUF_END + APALIS_TK1_K20_CAN_DEV_OFFSET(1))) { ret = canx_registers(&slaveXfer, 1); can_read = 1; +#endif #ifdef BOARD_USES_ADC } else if ((slaveRxData[1] >= APALIS_TK1_K20_ADCREG) && (slaveRxData[1] <= APALIS_TK1_K20_ADC_CH3H)) { ret = adc_registers(&slaveXfer); diff --git a/source/gpio_ext.h b/source/gpio_ext.h index df9f323..39a9183 100644 --- a/source/gpio_ext.h +++ b/source/gpio_ext.h @@ -20,6 +20,10 @@ struct gpio_id{ struct gpio_id gpio_list [] = { {PORTA, GPIOA, 3}, {PORTA, GPIOA, 5}, +#ifdef TESTER_BUILD + {PORTA, GPIOA, 12}, + {PORTA, GPIOA, 13}, +#endif {PORTA, GPIOA, 17}, #ifndef BOARD_USES_ADC {PORTB, GPIOB, 0}, @@ -40,6 +44,10 @@ struct gpio_id gpio_list [] = { {PORTC, GPIOC, 4}, {PORTC, GPIOC, 6}, {PORTC, GPIOC, 7}, +#ifdef TESTER_BUILD + {PORTC, GPIOC, 16}, + {PORTC, GPIOC, 17}, +#endif {PORTD, GPIOD, 0}, {PORTD, GPIOD, 1}, {PORTD, GPIOD, 2}, @@ -55,7 +63,7 @@ struct gpio_id gpio_list [] = { {PORTD, GPIOD, 13}, {PORTD, GPIOD, 14}, {PORTD, GPIOD, 15}, -#ifndef SDK_DEBUGCONSOLE +#if !defined(SDK_DEBUGCONSOLE) || defined(TESTER_BUILD) {PORTE, GPIOE, 0}, {PORTE, GPIOE, 1}, #endif diff --git a/source/main.c b/source/main.c index c076e43..a6aa5eb 100644 --- a/source/main.c +++ b/source/main.c @@ -60,9 +60,11 @@ TaskHandle_t adc_task_handle; TaskHandle_t tsc_task_handle; #endif +#ifndef TESTER_BUILD TaskHandle_t can0_task_handle; TaskHandle_t can1_task_handle; TaskHandle_t can_tx_notify_task_handle; +#endif TaskHandle_t spi_task_handle; @@ -74,7 +76,9 @@ int main(void) { /* Init board hardware. */ BOARD_InitPins(); BOARD_BootClockRUN(); +#ifndef TESTER_BUILD BOARD_InitDebugConsole(); +#endif PRINTF("Apalis K20 Firmware Version %d.%d\r\n", FW_MAJOR, FW_MINOR); /* Create RTOS task */ @@ -82,7 +86,7 @@ int main(void) { { PRINTF("create SPI task error\r\n"); } - +#ifndef TESTER_BUILD if(xTaskCreate(can0_task, "CAN0_task", 1000L / sizeof(portSTACK_TYPE), NULL, 2, &can0_task_handle) != pdPASS) { PRINTF("create CAN0 task error\r\n"); @@ -97,7 +101,7 @@ int main(void) { { PRINTF("create CAN TX notify task error\r\n"); } - +#endif #ifdef BOARD_USES_ADC if(xTaskCreate(adc_task, "ADC_task", 1000L / sizeof(portSTACK_TYPE), NULL, 2, &adc_task_handle) != pdPASS) { diff --git a/utilities/fsl_debug_console.h b/utilities/fsl_debug_console.h index a3d3790..eb716d8 100644 --- a/utilities/fsl_debug_console.h +++ b/utilities/fsl_debug_console.h @@ -60,6 +60,9 @@ //#define SDK_DEBUGCONSOLE 1U #endif +#ifdef TESTER_BUILD +#undef SDK_DEBUGCONSOLE +#endif #if defined(SDK_DEBUGCONSOLE) && !(SDK_DEBUGCONSOLE) #include #endif -- cgit v1.2.3