From 2f86b533af3ca4aa813160476764dc7098a14c2d Mon Sep 17 00:00:00 2001 From: Peter Wittich Date: Mon, 13 Jan 2025 11:27:45 -0500 Subject: [PATCH] interrupts, etc for ADCs --- projects/prod_test/ADCMonitorTask.c | 2 +- projects/prod_test/CommandLineTask.c | 2 +- projects/prod_test/commands.c | 2 +- projects/prod_test/prod_test.c | 22 ++++++++++++++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/projects/prod_test/ADCMonitorTask.c b/projects/prod_test/ADCMonitorTask.c index 7c517a22..397bfc54 100644 --- a/projects/prod_test/ADCMonitorTask.c +++ b/projects/prod_test/ADCMonitorTask.c @@ -201,7 +201,7 @@ static void initADC0SecondSequence(void) } extern TaskHandle_t TaskNotifyADC; // ADC monitoring task. -void ADCMonitorTask(void *parameters) +void ADCMonitorTask(void *pvParameters) { // initialize to the current tick time TickType_t xLastWakeTime = xTaskGetTickCount(); diff --git a/projects/prod_test/CommandLineTask.c b/projects/prod_test/CommandLineTask.c index 6f569adb..b71b3bb6 100644 --- a/projects/prod_test/CommandLineTask.c +++ b/projects/prod_test/CommandLineTask.c @@ -58,7 +58,7 @@ BaseType_t help_command_fcn(int argc, char **argv, char *m) if (left < len) { return pdTRUE; } - copied += snprintf(m + copied, SCRATCH_SIZE - copied, "%s:\r\n %s", + copied += snprintf(m + copied, SCRATCH_SIZE - copied, "%s:\r\n %s\r\n", commands[i].commandstr, commands[i].helpstr); } i = 0; diff --git a/projects/prod_test/commands.c b/projects/prod_test/commands.c index 557812fd..182df5ac 100644 --- a/projects/prod_test/commands.c +++ b/projects/prod_test/commands.c @@ -100,7 +100,7 @@ BaseType_t power_off_ctl(int argc, char **argv, char *m) { disable_ps(); snprintf(m, SCRATCH_SIZE, "Power off\r\n"); - return pdTRUE; + return pdFALSE; } // direct copy paste from other project? diff --git a/projects/prod_test/prod_test.c b/projects/prod_test/prod_test.c index dd1e6165..4a982acd 100644 --- a/projects/prod_test/prod_test.c +++ b/projects/prod_test/prod_test.c @@ -9,6 +9,7 @@ #include "driverlib/sysctl.h" #include "driverlib/rom.h" #include "driverlib/rom_map.h" +#include "driverlib/adc.h" #include "inc/hw_ints.h" // local includes @@ -30,6 +31,7 @@ SemaphoreHandle_t xUARTMutex = 0; void vCommandLineTask(void *pvParameters); +void ADCMonitorTask(void *pvParameters); //***************************************************************************** // @@ -57,6 +59,25 @@ void SystemInit(void) // initialize all pins, using file setup by TI PINMUX tool PinoutSet(); + // ADC + // initialize the ADCs. + ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); + ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC1); + // Set the reference to external + ROM_ADCReferenceSet(ADC0_BASE, ADC_REF_EXT_3V); + ROM_ADCReferenceSet(ADC1_BASE, ADC_REF_EXT_3V); + ROM_ADCIntEnable(ADC0_BASE, 1); // enable interrupt for sequence 1 + ROM_ADCIntEnable(ADC1_BASE, 0); // enable interrupt for sequence 0 + // clear the interrupts + ROM_ADCIntClear(ADC0_BASE, 1); + ROM_ADCIntClear(ADC1_BASE, 0); + // FreeRTOS insists that the priority of interrupts be set up like this. + ROM_IntPrioritySet(INT_ADC0SS1, configKERNEL_INTERRUPT_PRIORITY); + ROM_IntPrioritySet(INT_ADC1SS0, configKERNEL_INTERRUPT_PRIORITY); + + ROM_IntEnable(INT_ADC0SS1); + ROM_IntEnable(INT_ADC1SS0); + // initialize interrupts UART0Init(g_ui32SysClock); // ZYNQ UART initI2C1(g_ui32SysClock); // controller for power supplies @@ -125,6 +146,7 @@ __attribute__((noreturn)) int main(void) xUARTMutex = xSemaphoreCreateMutex(); xTaskCreate(vCommandLineTask, "CLIZY", 512, &cli_uart, tskIDLE_PRIORITY + 4, NULL); + xTaskCreate(ADCMonitorTask, "ADC", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 4, NULL); Print("\r\n----------------------------\r\n"); Print("Staring Apollo CM MCU Production Test firmware ");