uart - rx in it mode, tx in blocking mode
This commit is contained in:
parent
3cafc5aa92
commit
bec6f26366
15
.cproject
15
.cproject
@ -146,6 +146,7 @@
|
||||
<buildTargets>
|
||||
<target name="all" path="software/source/test/firmware/kernel/list" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>all</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
@ -153,6 +154,7 @@
|
||||
</target>
|
||||
<target name="clean" path="software/source/test/firmware/kernel/list" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>clean</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
@ -160,7 +162,6 @@
|
||||
</target>
|
||||
<target name="distclean" path="software/source" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>distclean</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
@ -216,6 +217,7 @@
|
||||
</target>
|
||||
<target name="all" path="software/test/firmware/kernel/list" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>all</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
@ -247,6 +249,7 @@
|
||||
</target>
|
||||
<target name="distclean" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>distclean</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
@ -276,6 +279,14 @@
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="shell test" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>TEST_APP=shell BOARD=stm32f4-discovery DEBUG=y</buildArguments>
|
||||
<buildTarget>test</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>false</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="msp430-ccrf example_radio_rx all" path="software/source/test" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments>APP=example_radio_rx BOARD=msp430-ccrf DEBUG=y</buildArguments>
|
||||
@ -302,6 +313,7 @@
|
||||
</target>
|
||||
<target name="all" path="software/source/test/firmware/kernel/ringbuffer" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>all</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
@ -309,6 +321,7 @@
|
||||
</target>
|
||||
<target name="clean" path="software/source/test/firmware/kernel/ringbuffer" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>make</buildCommand>
|
||||
<buildArguments/>
|
||||
<buildTarget>clean</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
|
@ -19,13 +19,29 @@ struct stm32f4_uart_obj {
|
||||
UART_HandleTypeDef *uart2_handle;
|
||||
UART_HandleTypeDef *uart3_handle;
|
||||
UART_HandleTypeDef *uart6_handle;
|
||||
const void *uart1_callback; //!< Interrupt callback.
|
||||
const void *uart1_parameter; //!< argument for the callback.
|
||||
const void *uart2_callback; //!< Interrupt callback.
|
||||
const void *uart2_parameter; //!< argument for the callback.
|
||||
const void *uart3_callback; //!< Interrupt callback.
|
||||
const void *uart3_parameter; //!< argument for the callback.
|
||||
const void *uart6_callback; //!< Interrupt callback.
|
||||
const void *uart6_parameter; //!< argument for the callback.
|
||||
};
|
||||
|
||||
static volatile struct stm32f4_uart_obj uart_obj = {
|
||||
.uart1_handle = NULL,
|
||||
.uart1_callback = NULL,
|
||||
.uart1_parameter = NULL,
|
||||
.uart2_handle = NULL,
|
||||
.uart2_callback = NULL,
|
||||
.uart2_parameter = NULL,
|
||||
.uart3_handle = NULL,
|
||||
.uart3_callback = NULL,
|
||||
.uart3_parameter = NULL,
|
||||
.uart6_handle = NULL,
|
||||
.uart6_callback = NULL,
|
||||
.uart6_parameter = NULL,
|
||||
};
|
||||
|
||||
int stm32f4_uart_open(const void *this)
|
||||
@ -63,6 +79,8 @@ int stm32f4_uart_open(const void *this)
|
||||
HAL_UART_Init(uart->uart_handle);
|
||||
HAL_NVIC_SetPriority(irq_type, 5, 1);
|
||||
HAL_NVIC_EnableIRQ(USART1_IRQn);
|
||||
__HAL_UART_ENABLE_IT(uart->uart_handle, UART_IT_RXNE);
|
||||
__HAL_UART_DISABLE_IT(uart->uart_handle, UART_IT_TXE);
|
||||
|
||||
return (0);
|
||||
}
|
||||
@ -99,6 +117,8 @@ int stm32f4_uart_close(const void *this)
|
||||
|
||||
int stm32f4_uart_read(const void *this, char *buffer, int len)
|
||||
{
|
||||
struct stm32f4_uart *uart = (struct stm32f4_uart *)this;
|
||||
*buffer = uart->uart_handle->Instance->DR;
|
||||
return (1);
|
||||
}
|
||||
|
||||
@ -107,12 +127,29 @@ int stm32f4_uart_write(const void *this, const char *buffer, int len)
|
||||
if(NULL == this)
|
||||
return -1;
|
||||
struct stm32f4_uart *uart = (struct stm32f4_uart *)this;
|
||||
HAL_UART_Transmit_IT(uart->uart_handle, (uint8_t *)buffer, len);
|
||||
HAL_UART_Transmit(uart->uart_handle, (uint8_t *)buffer, len, 1000);
|
||||
return len;
|
||||
}
|
||||
|
||||
int stm32f4_uart_set_cb(const void *this, const void *callback, const void *param)
|
||||
{
|
||||
struct stm32f4_uart *uart = (struct stm32f4_uart *)this;
|
||||
if(uart->uart_handle->Instance == USART1) {
|
||||
uart_obj.uart1_callback = callback;
|
||||
uart_obj.uart1_parameter = param;
|
||||
}
|
||||
else if(uart->uart_handle->Instance == USART2) {
|
||||
uart_obj.uart2_callback = callback;
|
||||
uart_obj.uart2_parameter = param;
|
||||
}
|
||||
else if(uart->uart_handle->Instance == USART3) {
|
||||
uart_obj.uart3_callback = callback;
|
||||
uart_obj.uart3_parameter = param;
|
||||
}
|
||||
else if(uart->uart_handle->Instance == USART6) {
|
||||
uart_obj.uart6_callback = callback;
|
||||
uart_obj.uart6_parameter = param;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -120,6 +157,14 @@ int stm32f4_uart_set_cb(const void *this, const void *callback, const void *para
|
||||
void USART1_IRQHandler(void)
|
||||
{
|
||||
enter_isr();
|
||||
HAL_UART_IRQHandler(uart_obj.uart1_handle);
|
||||
uint32_t tmp1 = 0U, tmp2 = 0U;
|
||||
tmp1 = __HAL_UART_GET_FLAG(uart_obj.uart1_handle, UART_FLAG_RXNE);
|
||||
tmp2 = __HAL_UART_GET_IT_SOURCE(uart_obj.uart1_handle, UART_IT_RXNE);
|
||||
if((tmp1 != RESET) && (tmp2 != RESET)) {
|
||||
if(uart_obj.uart1_callback) {
|
||||
void (*cb)(const void *) = uart_obj.uart1_callback;
|
||||
cb(uart_obj.uart1_parameter);
|
||||
}
|
||||
}
|
||||
exit_isr();
|
||||
}
|
||||
|
43
source/test/shell/main.c
Normal file
43
source/test/shell/main.c
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
|
||||
/*
|
||||
* main.c
|
||||
*
|
||||
* Created on: Aug 2, 2016
|
||||
* Author: tkl
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "driver.h"
|
||||
#include "board.h"
|
||||
#include "stack.h"
|
||||
#include "queue.h"
|
||||
#include "kernel.h"
|
||||
#include "driver.h"
|
||||
#include "list.h"
|
||||
#include "shell.h"
|
||||
|
||||
void *uname_fct(const char *line)
|
||||
{
|
||||
if(NULL == line)
|
||||
return NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct command cmd = {
|
||||
.command = "uname",
|
||||
.command_callback = uname_fct
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
board_init();
|
||||
shell_init(&uart_1);
|
||||
shell_add_command(&cmd);
|
||||
schedule_start();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
1
source/test/shell/shell.mk
Normal file
1
source/test/shell/shell.mk
Normal file
@ -0,0 +1 @@
|
||||
SRC_DIR += source/test/shell
|
Loading…
Reference in New Issue
Block a user