Skip to content

Commit

Permalink
Add debug. Various minor cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
chintal committed Jan 12, 2025
1 parent b5ee7f1 commit 3bfa367
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 74 deletions.
75 changes: 11 additions & 64 deletions include/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,32 +116,13 @@
*/
/**@{*/
#define APP_ENABLE_TIMER 1

#define APP_ENABLE_TIM1 0 // ADV 16b 4CC DMA UpDown

#define APP_ENABLE_TIM2 0 // GP 32b 4CC DMA UpDown
#define APP_ENABLE_TIM3 0 // GP 32b 4CC DMA UpDown
#define APP_ENABLE_TIM4 0 // GP 32b 4CC DMA UpDown
#define APP_ENABLE_TIM5 0 // GP 32b 4CC DMA UpDown

#define APP_ENABLE_TIM6 0 // Basic 16b 0CC DMA
#define APP_ENABLE_TIM7 0 // Basic 16b 0CC DMA

#define APP_ENABLE_TIM9 0 // GP 16b 2CC
#define APP_ENABLE_TIM12 0 // GP 16b 2CC
#define APP_ENABLE_TIM13 0 // GP 16b 1CC
#define APP_ENABLE_TIM14 0 // GP 16b 1CC
// GP 16b 2CC DMA
#define APP_ENABLE_TIM15 1

#define APP_ENABLE_TIM15 1 // GP 16b 2CC DMA
#define APP_ENABLE_TIM16 0 // GP 16b 1CC DMA
#define APP_ENABLE_TIM17 0 // GP 16b 1CC DMA

#define uC_TIM15_INTFNUM 0
#define uC_TIM15_CYCLE_FREQ 1500000
#define uC_TIM15_INTERRUPTS_ENABLE 0
#define uC_TIM15_INTERRUPT_TOP_ENABLE 0
#define uC_TIM15_CH1_OUTPUT_MODE TIMER_OUTMODE_TOGGLE
#define uC_TIM15_TRIGGEN_SRC TIMER_TRIGGEN_TOP
#define uC_TIM15_CH1_OUTPUT_MODE TIMER_OUTMODE_TOGGLE
#define uC_TIM15_TRIGGEN_SRC TIMER_TRIGGEN_TOP
/**@}*/

/**
Expand All @@ -150,13 +131,6 @@
* Not implemented
*/
/**@{*/
#define APP_ENABLE_LPTIMER 0

#define APP_ENABLE_LPTIM1 0 // LP 16b 2CC DMA
#define APP_ENABLE_LPTIM2 0 // LP 16b 2CC DMA
#define APP_ENABLE_LPTIM3 0 // LP 16b 2CC DMA
#define APP_ENABLE_LPTIM4 0 // LP 16b 0CC
#define APP_ENABLE_LPTIM5 0 // LP 16b 0CC
/**@}*/


Expand Down Expand Up @@ -207,7 +181,9 @@
/**
* @name Application UART Configuration
*/
/**@{*/
/**@{*/
#define APP_ENABLE_UART 1

#define APP_ENABLE_UART1 0 // A
#define APP_ENABLE_UART2 0 // B
#define APP_ENABLE_UART3 1 // Backchannel
Expand Down Expand Up @@ -321,41 +297,12 @@
*/
/**@{*/
#define APP_ENABLE_DMA 1

#define APP_ENABLE_DMA1_CH12 1 // HPDMA for memcpy
#define APP_ENABLE_DMA1_CH13 1 // HPDMA for ADC1

#define APP_ENABLE_DMA1_CH0 0
#define APP_ENABLE_DMA1_CH1 0
#define APP_ENABLE_DMA1_CH2 0
#define APP_ENABLE_DMA1_CH3 0
#define APP_ENABLE_DMA1_CH4 0
#define APP_ENABLE_DMA1_CH5 0
#define APP_ENABLE_DMA1_CH6 0
#define APP_ENABLE_DMA1_CH7 0
#define APP_ENABLE_DMA1_CH8 0
#define APP_ENABLE_DMA1_CH9 0
#define APP_ENABLE_DMA1_CH10 0
#define APP_ENABLE_DMA1_CH11 0
#define APP_ENABLE_DMA1_CH12 1
#define APP_ENABLE_DMA1_CH13 1 // DMA for ADC1
#define APP_ENABLE_DMA1_CH14 0
#define APP_ENABLE_DMA1_CH15 0
#define APP_ENABLE_DMA2_CH12 1 // GPDMA for memcpy

#define APP_ENABLE_DMA2_CH0 0
#define APP_ENABLE_DMA2_CH1 0
#define APP_ENABLE_DMA2_CH2 0
#define APP_ENABLE_DMA2_CH3 0
#define APP_ENABLE_DMA2_CH4 0
#define APP_ENABLE_DMA2_CH5 0
#define APP_ENABLE_DMA2_CH6 0
#define APP_ENABLE_DMA2_CH7 0
#define APP_ENABLE_DMA2_CH8 0
#define APP_ENABLE_DMA2_CH9 0
#define APP_ENABLE_DMA2_CH10 0
#define APP_ENABLE_DMA2_CH11 0
#define APP_ENABLE_DMA2_CH12 1
#define APP_ENABLE_DMA2_CH13 0
#define APP_ENABLE_DMA2_CH14 0
#define APP_ENABLE_DMA2_CH15 0

#define uC_DMA1_CH13_TYPE DMA_CHN_TYPE_CIRCULAR
#define uC_DMA1_CH13_PRIORITY DMA_PRIORITY_IMMEDIATE
/**@}*/
Expand Down
4 changes: 2 additions & 2 deletions src/demos/uart_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tm_sdelta_t uart_bare_period = 100;

void uart_bare_send(void) {
if (*(HAL_SFR_t *)(uart_if[DEBUG_TRANSPORT_INTFNUM]->hwif->base + OFS_UART_ISR) & USART_ISR_TXE_TXFNF) {
uart_putc_bare(DEBUG_TRANSPORT_INTFNUM, 'a');
uart_putc_bare(DEBUG_TRANSPORT_INTFNUM, 'a');
}
}

Expand All @@ -25,7 +25,7 @@ void uart_buffered_send(void) {


void start_uart_demo(void) {
uart_vprintf(DEBUG_TRANSPORT_INTFNUM, "UART example %d\n", 12);
uart_printf(DEBUG_TRANSPORT_INTFNUM, "UART example %d\n", 12);
tm_current_time(&uart_bare_start);
tm_cron_create_job_abs(&uart_bare_job, &uart_buffered_send, &uart_bare_start, &uart_bare_period);
}
4 changes: 2 additions & 2 deletions src/tasks/usb_task.c → src/demos/usbcdc_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <application.h>
#include <tusb.h>
#include "usb_task.h"
#include "usbcdc_demo.h"
#include <hal/uc/usb.h>
#include <hal/uc/usbcdc.h>

Expand Down Expand Up @@ -34,7 +34,7 @@ static void cdc_write_task(void) {
}
}

void usbcdc_bare_task(void){
void usbcdc_demo_task(void){
#if APP_ENABLE_USB_DEVICE
cdc_read_task();
cdc_write_task();
Expand Down
3 changes: 3 additions & 0 deletions src/demos/usbcdc_demo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@


void usbcdc_demo_task(void);
11 changes: 8 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
#include <modbus/modbus.h>

#include <blink.h>
#include <tasks/usb_task.h>

#include <demos/itcm_demo.h>
#include <demos/adc_demo.h>
#include <demos/dma_demo.h>
#include <demos/uart_demo.h>
#include <demos/usbcdc_demo.h>

ucdm_addr_t next_address;

Expand Down Expand Up @@ -131,8 +131,13 @@ int main(void) {
ucdm_address = setup_application(ucdm_address);

// itcm_demo();
start_uart_demo();
// start_uart_demo();
// setup_dma_demo();
debug_printf("Hello, World\n");
// _debug_printf("%d %x\n", 12, 12);
debug_printf("%d %x %d %f\n", 12, 12, 12, 1.3);
debug_putchar('x');

setup_adc_demo();
timer_set_mode(uC_TIM15_INTFNUM, TIMER_MODE_PERIODIC);

Expand All @@ -153,7 +158,7 @@ int main(void) {
#if APP_ENABLE_DMA
dma_poll();
#endif
// usbcdc_bare_task();
// usbcdc_demo_task();
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/tasks/usb_task.h

This file was deleted.

0 comments on commit 3bfa367

Please sign in to comment.