Get CLI functioning in SAMD20 demo.
This commit is contained in:
Binary file not shown.
@ -405,7 +405,6 @@
|
||||
<Value>../../../../../FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI</Value>
|
||||
</ListValues>
|
||||
</armgcc.compiler.directories.IncludePaths>
|
||||
<armgcc.compiler.optimization.level>Optimize (-O1)</armgcc.compiler.optimization.level>
|
||||
<armgcc.compiler.optimization.OtherFlags>-fdata-sections</armgcc.compiler.optimization.OtherFlags>
|
||||
<armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
|
||||
<armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel>
|
||||
@ -499,6 +498,12 @@
|
||||
<GenerateEepFile>True</GenerateEepFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="src\Sample-CLI-commands.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<Compile Include="src\UARTCommandConsole.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
<None Include="src\ASF\common\services\serial\sam0_usart\usart_serial.h">
|
||||
<SubType>compile</SubType>
|
||||
</None>
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,77 @@
|
||||
/*
|
||||
FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd.
|
||||
|
||||
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* FreeRTOS provides completely free yet professionally developed, *
|
||||
* robust, strictly quality controlled, supported, and cross *
|
||||
* platform software that has become a de facto standard. *
|
||||
* *
|
||||
* Help yourself get started quickly and support the FreeRTOS *
|
||||
* project by purchasing a FreeRTOS tutorial book, reference *
|
||||
* manual, or both from: http://www.FreeRTOS.org/Documentation *
|
||||
* *
|
||||
* Thank you! *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
This file is part of the FreeRTOS distribution.
|
||||
|
||||
FreeRTOS is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License (version 2) as published by the
|
||||
Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
|
||||
|
||||
>>! NOTE: The modification to the GPL is included to allow you to distribute
|
||||
>>! a combined work that includes FreeRTOS without being obliged to provide
|
||||
>>! the source code for proprietary components outside of the FreeRTOS
|
||||
>>! kernel.
|
||||
|
||||
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. Full license text is available from the following
|
||||
link: http://www.freertos.org/a00114.html
|
||||
|
||||
1 tab == 4 spaces!
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* Having a problem? Start by reading the FAQ "My application does *
|
||||
* not run, what could be wrong?" *
|
||||
* *
|
||||
* http://www.FreeRTOS.org/FAQHelp.html *
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
http://www.FreeRTOS.org - Documentation, books, training, latest versions,
|
||||
license and Real Time Engineers Ltd. contact details.
|
||||
|
||||
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
|
||||
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
|
||||
compatible FAT file system, and our tiny thread aware UDP/IP stack.
|
||||
|
||||
http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
|
||||
Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
|
||||
licenses offer ticketed support, indemnification and middleware.
|
||||
|
||||
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
|
||||
engineered and independently SIL3 certified version for use in safety and
|
||||
mission critical applications that require provable dependability.
|
||||
|
||||
1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
#ifndef UART_COMMAND_CONSOLE_H
|
||||
#define UART_COMMAND_CONSOLE_H
|
||||
|
||||
/*
|
||||
* Create the task that implements a command console using the USB virtual com
|
||||
* port driver for intput and output.
|
||||
*/
|
||||
void vUARTCommandConsoleStart( uint16_t usStackSize, unsigned portBASE_TYPE uxPriority );
|
||||
|
||||
#endif /* UART_COMMAND_CONSOLE_H */
|
||||
|
||||
|
||||
|
@ -66,89 +66,32 @@
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
/* Demo app includes. */
|
||||
#include "UARTCommandConsole.h"
|
||||
|
||||
/* Library includes. */
|
||||
#include <asf.h>
|
||||
|
||||
void usart_read_callback(const struct usart_module *const usart_module);
|
||||
void usart_write_callback(const struct usart_module *const usart_module);
|
||||
static void prvSetupHardware( void );
|
||||
void configure_usart(void);
|
||||
void configure_usart_callbacks(void);
|
||||
void vApplicationMallocFailedHook( void );
|
||||
void vApplicationIdleHook( void );
|
||||
void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName );
|
||||
void vApplicationTickHook( void );
|
||||
|
||||
struct usart_module usart_instance;
|
||||
#define MAX_RX_BUFFER_LENGTH 5
|
||||
volatile uint8_t rx_buffer[MAX_RX_BUFFER_LENGTH];
|
||||
#define NUM 1024
|
||||
char cChars[ NUM ] = { 0 };
|
||||
|
||||
void usart_read_callback(const struct usart_module *const usart_module)
|
||||
{
|
||||
usart_write_buffer_job(&usart_instance, (uint8_t *)rx_buffer, MAX_RX_BUFFER_LENGTH);
|
||||
}
|
||||
|
||||
void usart_write_callback(const struct usart_module *const usart_module)
|
||||
{
|
||||
port_pin_toggle_output_level(LED_0_PIN);
|
||||
}
|
||||
|
||||
void configure_usart(void)
|
||||
{
|
||||
struct usart_config config_usart;
|
||||
usart_get_config_defaults(&config_usart);
|
||||
config_usart.baudrate = 115200;
|
||||
config_usart.mux_setting = EDBG_CDC_SERCOM_MUX_SETTING;
|
||||
config_usart.pinmux_pad0 = EDBG_CDC_SERCOM_PINMUX_PAD0;
|
||||
config_usart.pinmux_pad1 = EDBG_CDC_SERCOM_PINMUX_PAD1;
|
||||
config_usart.pinmux_pad2 = EDBG_CDC_SERCOM_PINMUX_PAD2;
|
||||
config_usart.pinmux_pad3 = EDBG_CDC_SERCOM_PINMUX_PAD3;
|
||||
while (usart_init(&usart_instance,
|
||||
EDBG_CDC_MODULE, &config_usart) != STATUS_OK) {
|
||||
}
|
||||
usart_enable(&usart_instance);
|
||||
}
|
||||
|
||||
void configure_usart_callbacks(void)
|
||||
{
|
||||
usart_register_callback(&usart_instance,
|
||||
usart_write_callback, USART_CALLBACK_BUFFER_TRANSMITTED);
|
||||
usart_register_callback(&usart_instance,
|
||||
usart_read_callback, USART_CALLBACK_BUFFER_RECEIVED);
|
||||
usart_enable_callback(&usart_instance, USART_CALLBACK_BUFFER_TRANSMITTED);
|
||||
usart_enable_callback(&usart_instance, USART_CALLBACK_BUFFER_RECEIVED);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
prvSetupHardware();
|
||||
vUARTCommandConsoleStart( ( configMINIMAL_STACK_SIZE * 3 ), tskIDLE_PRIORITY );
|
||||
|
||||
/* Start the scheduler. */
|
||||
vTaskStartScheduler();
|
||||
|
||||
configure_usart();
|
||||
configure_usart_callbacks();
|
||||
system_interrupt_enable_global();
|
||||
|
||||
uint8_t string[] = "Hello World!\r\n";
|
||||
usart_write_buffer_job(&usart_instance, string, sizeof(string));
|
||||
|
||||
|
||||
|
||||
while (true) {
|
||||
usart_read_buffer_job(&usart_instance,
|
||||
(uint8_t *)rx_buffer, MAX_RX_BUFFER_LENGTH);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if (port_pin_get_input_level(BUTTON_0_PIN) == BUTTON_0_ACTIVE) {
|
||||
port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE);
|
||||
} else {
|
||||
port_pin_set_output_level(LED_0_PIN, !LED_0_ACTIVE);
|
||||
}
|
||||
}
|
||||
/* If all is well, the scheduler will now be running, and the following line
|
||||
will never be reached. If the following line does execute, then there was
|
||||
insufficient FreeRTOS heap memory available for the idle and/or timer tasks
|
||||
to be created. See the memory management section on the FreeRTOS web site
|
||||
for more details. */
|
||||
for( ;; );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
Reference in New Issue
Block a user