Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
toki
components
freertos-portable
Commits
0f164c26
Commit
0f164c26
authored
Aug 15, 2020
by
Oliver Horst
Browse files
[merge] Integrated 'feature/uart-driver' branch
parents
67b191b6
7f99d9de
Changes
4
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
0f164c26
...
...
@@ -11,3 +11,4 @@ target_sources(
)
add_subdirectory
(
hal
)
add_subdirectory
(
drivers
)
drivers/CMakeLists.txt
0 → 100644
View file @
0f164c26
# SPDX-License-Identifier: MIT
cmake_minimum_required
(
VERSION 3.7 FATAL_ERROR
)
target_sources
(
freertos
#
PRIVATE
"
${
CMAKE_CURRENT_LIST_DIR
}
/uart.c"
)
drivers/LICENSE
0 → 100644
View file @
0f164c26
BSD with Attribution License
Copyright (c) 2015-2020 fortiss GmbH - Research Institute of the
Free State of Bavaria, Guerickestr. 25, 80805 Munich, Germany
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
4. Redistributions of any form whatsoever must retain the following
acknowledgment: 'This product includes software developed by the
fortiss GmbH -- Research Institute of the Free State of Bavaria,
Munich, Germany (https://www.fortiss.org/).'
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SPDX-License-Identifier: BSD-3-Clause-Attribution
drivers/uart.c
0 → 100644
View file @
0f164c26
/**
* \file
* \brief UART driver abstraction (platform specific part: xilinx zcu102).
*/
/******************************************************************************/
/*** Includes ***/
/******************************************************************************/
#include
"freertos/hal/drivers/uart.h"
#include
"xil/xparameters.h"
#include
"xil/drivers/xuartps.h"
/******************************************************************************/
/*** Declarations ***/
/******************************************************************************/
/******************************************************************************/
/*** Defines ***/
/******************************************************************************/
#define MAX_NUM_UART_CONTROLLERS 2U
/* Maximum number of supported UART
Controllers */
/******************************************************************************/
/*** Type definitions ***/
/******************************************************************************/
typedef
struct
{
BaseType_t
isCtrlInit
;
/* Is the controller already initialized? */
XUartPs
uartXilinxInst
;
/* Instances of Xilinx UART controller */
uint32_t
baudrate
;
/* Requested UART Baud Rate, in bit/s */
}
uartInstance_t
;
/******************************************************************************/
/*** Variables ***/
/******************************************************************************/
/* Instances of the UART controllers */
static
uartInstance_t
uartInstance
[
MAX_NUM_UART_CONTROLLERS
];
/******************************************************************************/
/*** Prototypes ***/
/******************************************************************************/
/******************************************************************************/
/*** Implementation ***/
/******************************************************************************/
void
hal_uart_setup
(
void
)
{
}
int
hal_uart_init_channel
(
hal_io_handle_t
handle
,
uint32_t
baudrate
)
{
uartInstance_t
*
uartInstPtr
;
XUartPs
*
xilUartPtr
;
XUartPs_Config
*
cfgPtr
;
uint32_t
status
;
if
(
MAX_NUM_UART_CONTROLLERS
<=
handle
)
{
/* Unsupported handle */
return
pdFAIL
;
}
else
{
uartInstPtr
=
&
uartInstance
[
handle
];
xilUartPtr
=
&
uartInstPtr
->
uartXilinxInst
;
cfgPtr
=
XUartPs_LookupConfig
(
handle
);
if
(
!
cfgPtr
)
{
return
pdFAIL
;
}
else
{
uartInstPtr
->
uartXilinxInst
.
Config
=
*
cfgPtr
;
}
status
=
XUartPs_CfgInitialize
(
xilUartPtr
,
&
xilUartPtr
->
Config
,
xilUartPtr
->
Config
.
BaseAddress
);
if
(
XST_SUCCESS
!=
status
)
{
return
pdFAIL
;
}
else
{
/* Run self-test on the UART controller. */
status
=
XUartPs_SelfTest
(
xilUartPtr
);
if
(
XST_SUCCESS
!=
status
)
{
return
pdFAIL
;
}
else
{
/* Set the baudrate. */
status
=
XUartPs_SetBaudRate
(
xilUartPtr
,
baudrate
);
if
(
XST_SUCCESS
!=
status
)
{
return
pdFAIL
;
}
/* Store the baudrate, for reconfiguring the controller in case
* of bus-off state. */
uartInstPtr
->
baudrate
=
baudrate
;
/* Enter Normal Mode. */
XUartPs_SetOperMode
(
xilUartPtr
,
XUARTPS_OPER_MODE_NORMAL
);
while
(
XUARTPS_OPER_MODE_NORMAL
!=
XUartPs_GetOperMode
(
xilUartPtr
)
);
uartInstPtr
->
isCtrlInit
=
pdTRUE
;
return
pdPASS
;
}
}
}
}
int
hal_uart_getchar
(
hal_io_handle_t
handle
,
uint8_t
*
ch
)
{
if
(
MAX_NUM_UART_CONTROLLERS
<=
handle
)
{
/* Unsupported handle */
return
pdFAIL
;
}
else
{
if
(
pdTRUE
==
uartInstance
[
handle
].
isCtrlInit
)
{
*
ch
=
XUartPs_RecvByte
(
uartInstance
[
handle
].
uartXilinxInst
.
Config
.
BaseAddress
);
return
pdPASS
;
}
return
pdFAIL
;
}
}
int
hal_uart_getchar_timeout
(
hal_io_handle_t
handle
,
uint8_t
*
ch
,
TickType_t
timeout
)
{
(
void
)
handle
;
(
void
)
*
ch
;
(
void
)
timeout
;
return
pdFAIL
;
}
int
hal_uart_putchar
(
hal_io_handle_t
handle
,
uint8_t
ch
)
{
if
(
MAX_NUM_UART_CONTROLLERS
<=
handle
)
{
/* Unsupported handle */
return
pdFAIL
;
}
else
{
if
(
pdTRUE
==
uartInstance
[
handle
].
isCtrlInit
)
{
XUartPs_SendByte
(
uartInstance
[
handle
].
uartXilinxInst
.
Config
.
BaseAddress
,
ch
);
return
pdPASS
;
}
return
pdFAIL
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment