/** * \brief LIN Application entry point. * * \return Unused (ANSI-C compatibility). */ int main(void) { /* Output example information */ console_example_info("LIN Example"); /* Configure Console interrupts */ printf("Initializing console interrupts\r\n"); console_set_rx_handler(_console_handler); console_enable_rx_interrupt(); /* Configure Timer/Counter */ _configure_tc(); /* Configure com port */ _init_com_master(); _init_com_slave(); /* main LIN program */ _display_menu(); do { switch (key) { case 'P': case 'p': case 'S': case 's': case 'I': case 'i': tc_stop(TC0, TC_CHANNEL); _process_button_evt(); _display_menu(); if (key == 'I' || key == 'i') tc_stop(TC0, 0); else tc_start(TC0, TC_CHANNEL); key = 0; break; default: break; } } while (key != 'q' && key != 'Q'); tc_stop(TC0, TC_CHANNEL); timer_wait(500); printf("\n\rEnd of demo\n\r"); while (1); }
/** * \brief classd Application entry point * \return Unused (ANSI-C compatibility) */ extern int main(void) { uint8_t key; uint8_t attn = INITIAL_ATTENUATION; /* disable watchdog */ wdt_disable(); /* configure console */ board_cfg_console(); /* output example information */ printf("-- CLASSD Example " SOFTPACK_VERSION " --\n\r"); printf("-- " BOARD_NAME "\n\r"); printf("-- Compiled: " __DATE__ " " __TIME__ " --\n\r"); /* configure PIO muxing for ClassD */ pio_configure(classd_pins, ARRAY_SIZE(classd_pins)); /* initialize ClassD DMA channel */ _initialize_dma(); /* configure ClassD */ _configure_classd(); _set_attenuation(attn); while (1) { _display_menu(); key = console_get_char(); printf("%c\r\n", key); if (key == '1') { _display_audio_info((const struct _wav_header *)music_data); } else if (key == '2') { _playback_without_dma(attn); } else if (key == '3') { _playback_with_dma(attn); } else if (key == '4') { _output_audio_pmc_clock_to_pck1(); } else if (key == '+') { if (attn > 1) { attn -= 3; _set_attenuation(attn); } else { printf("Attenuation is already at min (-1dB)\r\n"); } } else if (key == '-') { if (attn < 76) { attn += 3; _set_attenuation(attn); } else { printf("Attenuation is already at max (-76dB)\r\n"); } } } }
/** * \brief dma Application entry point * \return Unused (ANSI-C compatibility) */ extern int main(void) { uint8_t key; bool configured = false; /* Output example information */ console_example_info("XDMA Example"); /* Allocate a XDMA channel. */ xdmad_channel = xdmad_allocate_channel(XDMAD_PERIPH_MEMORY, XDMAD_PERIPH_MEMORY); if (!xdmad_channel) { printf("-E- Can't allocate XDMA channel\n\r"); return 0; } /* Display menu */ _display_menu(); while (1) { key = console_get_char(); if (key >= 'a' && key <= 'd') { dma_data_width = key - 'a'; _display_menu(); } else if (key >= '0' && key <= '3') { dma_src_addr_mode = key - '0'; _display_menu(); } else if (key >= '4' && key <= '7') { dma_dest_addr_mode = key - '4'; _display_menu(); } else if (key >= '8' && key <= '9') { dma_memset = key - '8'; if (dma_memset == 0 && dma_view == 0) { printf("-I- DMA View 0 cannot be used when MEMSET is in NORMAL mode, selecting DMA View 1 instead.\r\n"); dma_view = 1; } _display_menu(); } else if (key >= 'e' && key <= 'h') { dma_view = key - 'e'; if (dma_view == 0 && dma_memset == 0) { printf("-I- DMA View 0 can only be used when MEMSET is in HW mode, enabling HW mode.\r\n"); dma_memset = 1; } _display_menu(); } else if (key == 'S' || key == 's') { dma_mode = 1; _configure_transfer(); configured = true; } else if (key == 'M' || key == 'm') { dma_mode = 2; _configure_transfer(); configured = true; } else if (key == 'L' || key == 'l') { dma_mode = 3; _configure_transfer(); configured = true; } else if (key == 'H') { _display_menu(); } else if (configured && (key == 'T' || key == 't')) { printf("-I- Start XDMA transfer\n\r"); _start_dma_transfer(); configured = false; } } }