git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1882 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
3621ac37b0
commit
75792b3d6a
|
@ -10,15 +10,15 @@
|
||||||
<Set Header="RCST7" >
|
<Set Header="RCST7" >
|
||||||
<Section Header="Model" >
|
<Section Header="Model" >
|
||||||
<Property Header="GlobalMemory" Value="" Removable="1" />
|
<Property Header="GlobalMemory" Value="" Removable="1" />
|
||||||
|
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
</Set>
|
</Set>
|
||||||
|
|
||||||
</Config>
|
</Config>
|
||||||
|
|
||||||
</Options>
|
</Options>
|
||||||
|
|
||||||
</NodeC>
|
</NodeC>
|
||||||
<NodeC Path="..\..\os\kernel\src\chlists.c" Header="chlists.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chlists.obj" sate="0" />
|
<NodeC Path="..\..\os\kernel\src\chlists.c" Header="chlists.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chlists.obj" sate="0" />
|
||||||
<NodeC Path="..\..\os\kernel\src\chmboxes.c" Header="chmboxes.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chmboxes.obj" sate="0" />
|
<NodeC Path="..\..\os\kernel\src\chmboxes.c" Header="chmboxes.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chmboxes.obj" sate="0" />
|
||||||
|
@ -34,15 +34,15 @@
|
||||||
<Set Header="RCST7" >
|
<Set Header="RCST7" >
|
||||||
<Section Header="Model" >
|
<Section Header="Model" >
|
||||||
<Property Header="GlobalMemory" Value="" Removable="1" />
|
<Property Header="GlobalMemory" Value="" Removable="1" />
|
||||||
|
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
</Set>
|
</Set>
|
||||||
|
|
||||||
</Config>
|
</Config>
|
||||||
|
|
||||||
</Options>
|
</Options>
|
||||||
|
|
||||||
</NodeC>
|
</NodeC>
|
||||||
<NodeC Path="..\..\os\kernel\src\chsem.c" Header="chsem.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chsem.obj" sate="0" />
|
<NodeC Path="..\..\os\kernel\src\chsem.c" Header="chsem.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chsem.obj" sate="0" />
|
||||||
<NodeC Path="..\..\os\kernel\src\chsys.c" Header="chsys.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chsys.obj" sate="0" />
|
<NodeC Path="..\..\os\kernel\src\chsys.c" Header="chsys.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chsys.obj" sate="0" />
|
||||||
|
@ -53,17 +53,17 @@
|
||||||
<Set Header="RCST7" >
|
<Set Header="RCST7" >
|
||||||
<Section Header="Model" >
|
<Section Header="Model" >
|
||||||
<Property Header="GlobalMemory" Value="" Removable="1" />
|
<Property Header="GlobalMemory" Value="" Removable="1" />
|
||||||
|
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
</Set>
|
</Set>
|
||||||
|
|
||||||
</Config>
|
</Config>
|
||||||
|
|
||||||
</Options>
|
</Options>
|
||||||
|
|
||||||
</NodeC>
|
</NodeC>
|
||||||
|
|
||||||
</Group>
|
</Group>
|
||||||
<Group Header="test" Marker="-1" OutputFile="" sate="0" >
|
<Group Header="test" Marker="-1" OutputFile="" sate="0" >
|
||||||
<NodeC Path="..\..\test\test.c" Header="test.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\test.obj" sate="0" />
|
<NodeC Path="..\..\test\test.c" Header="test.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\test.obj" sate="0" />
|
||||||
|
@ -78,11 +78,11 @@
|
||||||
<NodeC Path="..\..\test\testqueues.c" Header="testqueues.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\testqueues.obj" sate="0" />
|
<NodeC Path="..\..\test\testqueues.c" Header="testqueues.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\testqueues.obj" sate="0" />
|
||||||
<NodeC Path="..\..\test\testsem.c" Header="testsem.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\testsem.obj" sate="0" />
|
<NodeC Path="..\..\test\testsem.c" Header="testsem.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\testsem.obj" sate="0" />
|
||||||
<NodeC Path="..\..\test\testthd.c" Header="testthd.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\testthd.obj" sate="0" />
|
<NodeC Path="..\..\test\testthd.c" Header="testthd.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\testthd.obj" sate="0" />
|
||||||
|
|
||||||
</Group>
|
</Group>
|
||||||
<Group Header="port" Marker="-1" OutputFile="" sate="0" >
|
<Group Header="port" Marker="-1" OutputFile="" sate="0" >
|
||||||
<NodeC Path="..\..\os\ports\RC\STM8\chcore.c" Header="chcore.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chcore.obj" sate="0" />
|
<NodeC Path="..\..\os\ports\RC\STM8\chcore.c" Header="chcore.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\chcore.obj" sate="0" />
|
||||||
|
|
||||||
</Group>
|
</Group>
|
||||||
<Group Header="hal" Marker="-1" OutputFile="" sate="0" >
|
<Group Header="hal" Marker="-1" OutputFile="" sate="0" >
|
||||||
<NodeC Path="..\..\os\hal\src\adc.c" Header="adc.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\adc.obj" sate="0" />
|
<NodeC Path="..\..\os\hal\src\adc.c" Header="adc.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\adc.obj" sate="0" />
|
||||||
|
@ -97,11 +97,11 @@
|
||||||
<NodeC Path="..\..\os\hal\platforms\STM8\hal_lld.c" Header="hal_lld.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\hal_lld.obj" sate="0" />
|
<NodeC Path="..\..\os\hal\platforms\STM8\hal_lld.c" Header="hal_lld.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\hal_lld.obj" sate="0" />
|
||||||
<NodeC Path="..\..\os\hal\platforms\STM8\serial_lld.c" Header="serial_lld.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\serial_lld.obj" sate="0" />
|
<NodeC Path="..\..\os\hal\platforms\STM8\serial_lld.c" Header="serial_lld.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\serial_lld.obj" sate="0" />
|
||||||
<NodeC Path="..\..\os\hal\platforms\STM8\pal_lld.c" Header="pal_lld.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\pal_lld.obj" sate="0" />
|
<NodeC Path="..\..\os\hal\platforms\STM8\pal_lld.c" Header="pal_lld.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\pal_lld.obj" sate="0" />
|
||||||
|
|
||||||
</Group>
|
</Group>
|
||||||
<Group Header="board" Marker="-1" OutputFile="" sate="0" >
|
<Group Header="board" Marker="-1" OutputFile="" sate="0" >
|
||||||
<NodeC Path="..\..\boards\RAISONANCE_REVA_STM8S\board.c" Header="board.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\board.obj" sate="0" />
|
<NodeC Path="..\..\boards\RAISONANCE_REVA_STM8S\board.c" Header="board.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\board.obj" sate="0" />
|
||||||
|
|
||||||
</Group>
|
</Group>
|
||||||
<NodeC Path=".\main.c" Header="main.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\main.obj" sate="0" />
|
<NodeC Path=".\main.c" Header="main.c" Marker="-1" OutputFile="..\STM8S-STM8S208-RC/bin\main.obj" sate="0" />
|
||||||
<Options>
|
<Options>
|
||||||
|
@ -109,21 +109,21 @@
|
||||||
<Set Header="ApplicationBuild" >
|
<Set Header="ApplicationBuild" >
|
||||||
<Section Header="General" >
|
<Section Header="General" >
|
||||||
<Property Header="TargetFamily" Value="ST7" />
|
<Property Header="TargetFamily" Value="ST7" />
|
||||||
|
|
||||||
</Section>
|
</Section>
|
||||||
<Section Header="Directories" >
|
<Section Header="Directories" >
|
||||||
<Property Header="IncDir" Value="$(RkitInc);$(RkitInc)\ST7;..\..\os\kernel\include;..\..\os\ports\RC\STM8;..\..\os\hal\include;..\..\os\hal\platforms\STM8;..\..\boards\RAISONANCE_REVA_STM8S;..\..\test" Removable="1" />
|
<Property Header="IncDir" Value="$(RkitInc);$(RkitInc)\ST7;..\..\os\kernel\include;..\..\os\ports\RC\STM8;..\..\os\hal\include;..\..\os\hal\platforms\STM8;..\..\boards\RAISONANCE_REVA_STM8S;..\..\test" Removable="1" />
|
||||||
<Property Header="OutDir" Value="$(ApplicationDir)/bin" Removable="1" />
|
<Property Header="OutDir" Value="$(ApplicationDir)/bin" Removable="1" />
|
||||||
<Property Header="ListDir" Value="$(ApplicationDir)/lst" Removable="1" />
|
<Property Header="ListDir" Value="$(ApplicationDir)/lst" Removable="1" />
|
||||||
<Property Header="LinkerOutputDir" Value="Output Directory" Removable="1" />
|
<Property Header="LinkerOutputDir" Value="Output Directory" Removable="1" />
|
||||||
|
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
</Set>
|
</Set>
|
||||||
<Set Header="Target" >
|
<Set Header="Target" >
|
||||||
<Section Header="ProcessorST7" >
|
<Section Header="ProcessorST7" >
|
||||||
<Property Header="Processor" Value="STM8S208MB" Removable="1" />
|
<Property Header="Processor" Value="STM8S208MB" Removable="1" />
|
||||||
|
|
||||||
</Section>
|
</Section>
|
||||||
<Section Header="ToolSetST7" >
|
<Section Header="ToolSetST7" >
|
||||||
<Property Header="BuildToolSetST7" Value="ST7\RaisonanceTools.config" Removable="1" />
|
<Property Header="BuildToolSetST7" Value="ST7\RaisonanceTools.config" Removable="1" />
|
||||||
|
@ -134,33 +134,33 @@
|
||||||
<Section Header="DebugST7" >
|
<Section Header="DebugST7" >
|
||||||
<Property Header="Startup" Value="1" Removable="1" />
|
<Property Header="Startup" Value="1" Removable="1" />
|
||||||
<Property Header="DebugTool_STM8" Value="RLINK_STM8" Removable="1" />
|
<Property Header="DebugTool_STM8" Value="RLINK_STM8" Removable="1" />
|
||||||
|
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
</Set>
|
</Set>
|
||||||
<Set Header="RCST7" >
|
<Set Header="RCST7" >
|
||||||
<Section Header="CodeGen" >
|
<Section Header="CodeGen" >
|
||||||
<Property Header="ENUMTYPE" Value="ET(CHAR)" Removable="1" />
|
<Property Header="ENUMTYPE" Value="ET(CHAR)" Removable="1" />
|
||||||
|
|
||||||
</Section>
|
</Section>
|
||||||
<Section Header="Model" >
|
<Section Header="Model" >
|
||||||
<Property Header="GlobalMemory" Value="DGC(DATA)" Removable="1" />
|
<Property Header="GlobalMemory" Value="DGC(DATA)" Removable="1" />
|
||||||
<Property Header="ModelP" Value="STM8(SMALL)" Removable="1" />
|
<Property Header="ModelP" Value="STM8(SMALL)" Removable="1" />
|
||||||
|
|
||||||
</Section>
|
</Section>
|
||||||
<Section Header="OPTIM" >
|
<Section Header="OPTIM" >
|
||||||
<Property Header="OTLEVEL" Value="3" Removable="1" />
|
<Property Header="OTLEVEL" Value="3" Removable="1" />
|
||||||
<Property Header="SPEEDSIZE" Value="SPEED" Removable="1" />
|
<Property Header="SPEEDSIZE" Value="SPEED" Removable="1" />
|
||||||
|
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
</Set>
|
</Set>
|
||||||
<Set Header="MAST7" >
|
<Set Header="MAST7" >
|
||||||
<Section Header="Set" >
|
<Section Header="Set" >
|
||||||
<Property Header="Defines" Value="STM8S208RB" Removable="1" />
|
<Property Header="Defines" Value="STM8S208RB" Removable="1" />
|
||||||
|
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
</Set>
|
</Set>
|
||||||
</Config>
|
</Config>
|
||||||
</Options>
|
</Options>
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
* ChibiOS/RT Articles and Code Examples:
|
* ChibiOS/RT Articles and Code Examples:
|
||||||
* - @subpage article_eclipse
|
* - @subpage article_eclipse
|
||||||
* - @subpage article_eclipse2
|
* - @subpage article_eclipse2
|
||||||
|
* - @subpage article_debug
|
||||||
* - @subpage article_create_thread
|
* - @subpage article_create_thread
|
||||||
* - @subpage article_interrupts
|
* - @subpage article_interrupts
|
||||||
* - @subpage article_wakeup
|
* - @subpage article_wakeup
|
||||||
|
|
|
@ -0,0 +1,138 @@
|
||||||
|
/*
|
||||||
|
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio.
|
||||||
|
|
||||||
|
This file is part of ChibiOS/RT.
|
||||||
|
|
||||||
|
ChibiOS/RT is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
ChibiOS/RT 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. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @page article_debug Debugging ChibiOS/RT applications
|
||||||
|
* ChibiOS/RT offers several mechanisms that can help in the debug phase of
|
||||||
|
* the development cycle.
|
||||||
|
*
|
||||||
|
* <h2>What this guide does not cover</h2>
|
||||||
|
* This guide assumes knowledge in following areas:
|
||||||
|
* - General knowledge of embedded development.
|
||||||
|
* - RTOS concepts.
|
||||||
|
* - Setup of your specific target hardware and toolchain.
|
||||||
|
* - Knowledge of your toolchain. The guide will explain what you need to do,
|
||||||
|
* not how it is done using you specific debugger, compiler, JTAG probe and
|
||||||
|
* target hardware.
|
||||||
|
* .
|
||||||
|
* <h2>Helpful debugging configuration settings</h2>
|
||||||
|
* There are several settings in your kernel configuration file
|
||||||
|
* (see @ref templates/chconf.h) that you may want to enable during
|
||||||
|
* debugging and in general during the whole development process.
|
||||||
|
* - @p CH_OPTIMIZE_SPEED=FALSE, this disables inlining into the kernel code
|
||||||
|
* and makes it easier to debug using your debugger, you may also want
|
||||||
|
* to reduce or disable compiler optimizations (-O0 using GCC).
|
||||||
|
* - @p CH_DBG_ENABLE_CHECKS=TRUE, this setting enables the checks on the
|
||||||
|
* API parameters, useful to understand if you are passing wrong parameters
|
||||||
|
* to the OS functions.
|
||||||
|
* - @p CH_DBG_ENABLE_ASSERTS=TRUE, this setting enables the OS internal
|
||||||
|
* consistency checks, this can trap several kind of errors in the user
|
||||||
|
* code (or in the kernel itself).
|
||||||
|
* - @p CH_DBG_ENABLE_STACK_CHECK=TRUE, this setting enables checks on
|
||||||
|
* threads stack overflow. Note that this option is not available in
|
||||||
|
* all ports, check your port documentation. If not supported then it
|
||||||
|
* is silently ignored, see also the article @ref article_stacks.
|
||||||
|
* - @p CH_DBG_FILL_THREADS=TRUE, this setting enables the threads workspace
|
||||||
|
* filling, this can help examining the stack usage from your debugger.
|
||||||
|
* .
|
||||||
|
* Note that all the failed checks lock the kernel into the @p port_halt()
|
||||||
|
* function. In order to assess what triggered the lock the global variable
|
||||||
|
* @p panic_msg must be inspected using the debugger, the variable is a
|
||||||
|
* pointer to an error message (a zero terminated string), the pointer may
|
||||||
|
* contain @p NULL if the lock was triggered by a stack overflow.
|
||||||
|
*
|
||||||
|
* <h2>Common errors and symptoms</h2>
|
||||||
|
* There are some common errors while using an RTOS, use the following
|
||||||
|
* table as a check list, if your problem is not a generic programming error
|
||||||
|
* then probably it is one of the following common RTOS/embedded related
|
||||||
|
* mistakes:
|
||||||
|
* - Insufficient stack allocated to one or more threads.<br>
|
||||||
|
* Common symptoms:
|
||||||
|
* - Target instability.
|
||||||
|
* - Target locked into the @p port_halt() function.
|
||||||
|
* - Target trapped into an exception handler (architecture dependent).
|
||||||
|
* - Target apparent self reset (not real resets usually).
|
||||||
|
* .
|
||||||
|
* - Insufficient stack allocated to the IRQ stack (in those architectures
|
||||||
|
* that have a separate IRQ stack, ARM as example).<br>
|
||||||
|
* Common symptoms:
|
||||||
|
* - Target instability.
|
||||||
|
* - Target trapped into an exception handler (architecture dependent).
|
||||||
|
* - Target apparent self reset (not real resets usually).
|
||||||
|
* .
|
||||||
|
* - Use of a non reentrant function from within an interrupt handler, as
|
||||||
|
* example most C runtime functions.<br>
|
||||||
|
* Common symptoms:
|
||||||
|
* - Target instability.
|
||||||
|
* - Unexpected application behavior.
|
||||||
|
* .
|
||||||
|
* - Missing use of a mutual exclusion mechanism to protect data
|
||||||
|
* (or non reentrant code) shared among multiple threads and/or
|
||||||
|
* threads and interrupt handlers, see also the article
|
||||||
|
* @ref article_mutual_exclusion.<br>
|
||||||
|
* Common symptoms:
|
||||||
|
* - Target instability.
|
||||||
|
* - Unexpected application behavior.
|
||||||
|
* .
|
||||||
|
* - Use of S-class or I-class APIs outside a proper lock state, see the
|
||||||
|
* @ref concepts article, specifically the @ref api_suffixes and
|
||||||
|
* @ref system_states sections.<br>
|
||||||
|
* Common symptoms:
|
||||||
|
* - Target instability.
|
||||||
|
* - Target trapped into an exception handler (architecture dependent).
|
||||||
|
* - Target apparent self reset (not real resets usually).
|
||||||
|
* .
|
||||||
|
* - Use of a non I-class API from an interrupt handler, see the
|
||||||
|
* @ref concepts article, specifically the @ref api_suffixes and
|
||||||
|
* @ref system_states sections.<br>
|
||||||
|
* Common symptoms:
|
||||||
|
* - Target instability.
|
||||||
|
* - Target trapped into an exception handler (architecture dependent).
|
||||||
|
* - Target apparent self reset (not real resets usually).
|
||||||
|
* .
|
||||||
|
* - Wrong threads priority assignment. One of the most critical things
|
||||||
|
* to do when designing an RTOS based application is to assign correct
|
||||||
|
* priorities to the threads in the system.<br>
|
||||||
|
* Common symptoms:
|
||||||
|
* - Excessive or unpredictable response times.
|
||||||
|
* - Threads that appear to be never executed (CPU intensive threads at
|
||||||
|
* higher priority).
|
||||||
|
* .
|
||||||
|
* .
|
||||||
|
* <h2>General suggestions</h2>
|
||||||
|
* For the less expert users, there are several things you may do in order
|
||||||
|
* to minimize the need for debugging:
|
||||||
|
* - Read carefully the documentation first.
|
||||||
|
* - Try to find a code examples for things are you going to do, good sources
|
||||||
|
* are: the documentation, the test code, under "./test" you will
|
||||||
|
* find examples for almost any API in the ChibiOS/RT kernel and most
|
||||||
|
* common RTOS related tasks, under "./testhal" there are examples
|
||||||
|
* regarding the various device drivers, the various demos contain
|
||||||
|
* good code samples too).
|
||||||
|
* - Start your application from an existing demos, add things one piece at
|
||||||
|
* time and test often, if you add too many things at once a small problem
|
||||||
|
* can become a debugging nightmare. Follow the cycle: think, implement,
|
||||||
|
* test, repeat.
|
||||||
|
* - If you are stuck for too much time then consider asking for advice.
|
||||||
|
* - Report bugs and problems, bugs can be fixed, problems can become new
|
||||||
|
* articles in the documentation (this and other documentation articles
|
||||||
|
* spawned from questions in the forum or in the tracker).
|
||||||
|
* - Never give up :-)
|
||||||
|
* .
|
||||||
|
*/
|
|
@ -18,8 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file AVR/serial_lld.c
|
* @file AVR/serial_lld.c
|
||||||
* @brief AVR low level serial driver code.
|
* @brief AVR low level serial driver code.
|
||||||
|
*
|
||||||
* @addtogroup AVR_SERIAL
|
* @addtogroup AVR_SERIAL
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
@ -34,18 +35,18 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART0 serial driver identifier.
|
* @brief USART0 serial driver identifier.
|
||||||
* @note The name does not follow the convention used in the other ports
|
* @note The name does not follow the convention used in the other ports
|
||||||
* (COMn) because a name conflict with the AVR headers.
|
* (COMn) because a name conflict with the AVR headers.
|
||||||
*/
|
*/
|
||||||
#if USE_AVR_USART0 || defined(__DOXYGEN__)
|
#if USE_AVR_USART0 || defined(__DOXYGEN__)
|
||||||
SerialDriver SD1;
|
SerialDriver SD1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART1 serial driver identifier.
|
* @brief USART1 serial driver identifier.
|
||||||
* @note The name does not follow the convention used in the other ports
|
* @note The name does not follow the convention used in the other ports
|
||||||
* (COMn) because a name conflict with the AVR headers.
|
* (COMn) because a name conflict with the AVR headers.
|
||||||
*/
|
*/
|
||||||
#if USE_AVR_USART1 || defined(__DOXYGEN__)
|
#if USE_AVR_USART1 || defined(__DOXYGEN__)
|
||||||
SerialDriver SD2;
|
SerialDriver SD2;
|
||||||
|
@ -56,7 +57,7 @@ SerialDriver SD2;
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Driver default configuration.
|
* @brief Driver default configuration.
|
||||||
*/
|
*/
|
||||||
static const SerialConfig default_config = {
|
static const SerialConfig default_config = {
|
||||||
UBRR(SERIAL_DEFAULT_BITRATE),
|
UBRR(SERIAL_DEFAULT_BITRATE),
|
||||||
|
@ -88,8 +89,9 @@ static void notify1(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART0 initialization.
|
* @brief USART0 initialization.
|
||||||
* @param[in] config the architecture-dependent serial driver configuration
|
*
|
||||||
|
* @param[in] config the architecture-dependent serial driver configuration
|
||||||
*/
|
*/
|
||||||
static void usart0_init(const SerialConfig *config) {
|
static void usart0_init(const SerialConfig *config) {
|
||||||
|
|
||||||
|
@ -101,7 +103,7 @@ static void usart0_init(const SerialConfig *config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART0 de-initialization.
|
* @brief USART0 de-initialization.
|
||||||
*/
|
*/
|
||||||
static void usart0_deinit(void) {
|
static void usart0_deinit(void) {
|
||||||
|
|
||||||
|
@ -118,8 +120,9 @@ static void notify2(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART1 initialization.
|
* @brief USART1 initialization.
|
||||||
* @param[in] config the architecture-dependent serial driver configuration
|
*
|
||||||
|
* @param[in] config the architecture-dependent serial driver configuration
|
||||||
*/
|
*/
|
||||||
static void usart1_init(const SerialConfig *config) {
|
static void usart1_init(const SerialConfig *config) {
|
||||||
|
|
||||||
|
@ -131,7 +134,7 @@ static void usart1_init(const SerialConfig *config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART1 de-initialization.
|
* @brief USART1 de-initialization.
|
||||||
*/
|
*/
|
||||||
static void usart1_deinit(void) {
|
static void usart1_deinit(void) {
|
||||||
|
|
||||||
|
@ -216,7 +219,7 @@ CH_IRQ_HANDLER(USART1_UDRE_vect) {
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Low level serial driver initialization.
|
* @brief Low level serial driver initialization.
|
||||||
*/
|
*/
|
||||||
void sd_lld_init(void) {
|
void sd_lld_init(void) {
|
||||||
|
|
||||||
|
@ -229,35 +232,38 @@ void sd_lld_init(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Low level serial driver configuration and (re)start.
|
* @brief Low level serial driver configuration and (re)start.
|
||||||
*
|
*
|
||||||
* @param[in] sdp pointer to a @p SerialDriver object
|
* @param[in] sdp pointer to a @p SerialDriver object
|
||||||
|
* @param[in] config the architecture-dependent serial driver configuration.
|
||||||
|
* If this parameter is set to @p NULL then a default
|
||||||
|
* configuration is used.
|
||||||
*/
|
*/
|
||||||
void sd_lld_start(SerialDriver *sdp) {
|
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
|
||||||
|
|
||||||
if (sdp->config == NULL)
|
if (config == NULL)
|
||||||
sdp->config = &default_config;
|
config = &default_config;
|
||||||
|
|
||||||
#if USE_AVR_USART0
|
#if USE_AVR_USART0
|
||||||
if (&SD1 == sdp) {
|
if (&SD1 == sdp) {
|
||||||
usart0_init(sdp->config);
|
usart0_init(config);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if USE_AVR_USART1
|
#if USE_AVR_USART1
|
||||||
if (&SD2 == sdp) {
|
if (&SD2 == sdp) {
|
||||||
usart1_init(sdp->config);
|
usart1_init(config);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Low level serial driver stop.
|
* @brief Low level serial driver stop.
|
||||||
* @details De-initializes the USART, stops the associated clock, resets the
|
* @details De-initializes the USART, stops the associated clock, resets the
|
||||||
* interrupt vector.
|
* interrupt vector.
|
||||||
*
|
*
|
||||||
* @param[in] sdp pointer to a @p SerialDriver object
|
* @param[in] sdp pointer to a @p SerialDriver object
|
||||||
*/
|
*/
|
||||||
void sd_lld_stop(SerialDriver *sdp) {
|
void sd_lld_stop(SerialDriver *sdp) {
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file AVR/serial_lld.h
|
* @file AVR/serial_lld.h
|
||||||
* @brief AVR low level serial driver header.
|
* @brief AVR low level serial driver header.
|
||||||
|
*
|
||||||
* @addtogroup AVR_SERIAL
|
* @addtogroup AVR_SERIAL
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
@ -38,18 +39,18 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART0 driver enable switch.
|
* @brief USART0 driver enable switch.
|
||||||
* @details If set to @p TRUE the support for USART0 is included.
|
* @details If set to @p TRUE the support for USART0 is included.
|
||||||
* @note The default is @p FALSE.
|
* @note The default is @p FALSE.
|
||||||
*/
|
*/
|
||||||
#if !defined(USE_AVR_USART0) || defined(__DOXYGEN__)
|
#if !defined(USE_AVR_USART0) || defined(__DOXYGEN__)
|
||||||
#define USE_AVR_USART0 TRUE
|
#define USE_AVR_USART0 TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART1 driver enable switch.
|
* @brief USART1 driver enable switch.
|
||||||
* @details If set to @p TRUE the support for USART1 is included.
|
* @details If set to @p TRUE the support for USART1 is included.
|
||||||
* @note The default is @p TRUE.
|
* @note The default is @p TRUE.
|
||||||
*/
|
*/
|
||||||
#if !defined(USE_AVR_USART1) || defined(__DOXYGEN__)
|
#if !defined(USE_AVR_USART1) || defined(__DOXYGEN__)
|
||||||
#define USE_AVR_USART1 TRUE
|
#define USE_AVR_USART1 TRUE
|
||||||
|
@ -64,12 +65,12 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Serial Driver condition flags type.
|
* @brief Serial Driver condition flags type.
|
||||||
*/
|
*/
|
||||||
typedef uint8_t sdflags_t;
|
typedef uint8_t sdflags_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief AVR Serial Driver configuration structure.
|
* @brief AVR Serial Driver configuration structure.
|
||||||
* @details An instance of this structure must be passed to @p sdStart()
|
* @details An instance of this structure must be passed to @p sdStart()
|
||||||
* in order to configure and start a serial driver operations.
|
* in order to configure and start a serial driver operations.
|
||||||
*/
|
*/
|
||||||
|
@ -85,14 +86,12 @@ typedef struct {
|
||||||
} SerialConfig;
|
} SerialConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief @p SerialDriver specific data.
|
* @brief @p SerialDriver specific data.
|
||||||
*/
|
*/
|
||||||
#define _serial_driver_data \
|
#define _serial_driver_data \
|
||||||
_base_asynchronous_channel_data \
|
_base_asynchronous_channel_data \
|
||||||
/* Driver state.*/ \
|
/* Driver state.*/ \
|
||||||
sdstate_t state; \
|
sdstate_t state; \
|
||||||
/* Current configuration data.*/ \
|
|
||||||
const SerialConfig *config; \
|
|
||||||
/* Input queue.*/ \
|
/* Input queue.*/ \
|
||||||
InputQueue iqueue; \
|
InputQueue iqueue; \
|
||||||
/* Output queue.*/ \
|
/* Output queue.*/ \
|
||||||
|
@ -112,8 +111,8 @@ typedef struct {
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Macro for baud rate computation.
|
* @brief Macro for baud rate computation.
|
||||||
* @note Make sure the final baud rate is within tolerance.
|
* @note Make sure the final baud rate is within tolerance.
|
||||||
*/
|
*/
|
||||||
#define UBRR(b) ((F_CPU / (b << 4)) - 1)
|
#define UBRR(b) ((F_CPU / (b << 4)) - 1)
|
||||||
|
|
||||||
|
@ -132,7 +131,7 @@ extern SerialDriver SD2;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
void sd_lld_init(void);
|
void sd_lld_init(void);
|
||||||
void sd_lld_start(SerialDriver *sdp);
|
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config);
|
||||||
void sd_lld_stop(SerialDriver *sdp);
|
void sd_lld_stop(SerialDriver *sdp);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,16 +58,17 @@ static const SerialConfig default_config = {
|
||||||
* @brief UART initialization.
|
* @brief UART initialization.
|
||||||
*
|
*
|
||||||
* @param[in] sdp communication channel associated to the UART
|
* @param[in] sdp communication channel associated to the UART
|
||||||
|
* @param[in] config the architecture-dependent serial driver configuration
|
||||||
*/
|
*/
|
||||||
static void uart_init(SerialDriver *sdp) {
|
static void uart_init(SerialDriver *sdp, const SerialConfig *config) {
|
||||||
LPC_UART_TypeDef *u = sdp->uart;
|
LPC_UART_TypeDef *u = sdp->uart;
|
||||||
|
|
||||||
uint32_t div = LPC11xx_UART_PCLK / (sdp->config->sc_speed << 4);
|
uint32_t div = LPC11xx_UART_PCLK / (config->sc_speed << 4);
|
||||||
u->LCR = sdp->config->sc_lcr | LCR_DLAB;
|
u->LCR = config->sc_lcr | LCR_DLAB;
|
||||||
u->DLL = div;
|
u->DLL = div;
|
||||||
u->DLM = div >> 8;
|
u->DLM = div >> 8;
|
||||||
u->LCR = sdp->config->sc_lcr;
|
u->LCR = config->sc_lcr;
|
||||||
u->FCR = FCR_ENABLE | FCR_RXRESET | FCR_TXRESET | sdp->config->sc_fcr;
|
u->FCR = FCR_ENABLE | FCR_RXRESET | FCR_TXRESET | config->sc_fcr;
|
||||||
u->ACR = 0;
|
u->ACR = 0;
|
||||||
u->FDR = 0x10;
|
u->FDR = 0x10;
|
||||||
u->TER = TER_ENABLE;
|
u->TER = TER_ENABLE;
|
||||||
|
@ -242,11 +243,14 @@ void sd_lld_init(void) {
|
||||||
* @brief Low level serial driver configuration and (re)start.
|
* @brief Low level serial driver configuration and (re)start.
|
||||||
*
|
*
|
||||||
* @param[in] sdp pointer to a @p SerialDriver object
|
* @param[in] sdp pointer to a @p SerialDriver object
|
||||||
|
* @param[in] config the architecture-dependent serial driver configuration.
|
||||||
|
* If this parameter is set to @p NULL then a default
|
||||||
|
* configuration is used.
|
||||||
*/
|
*/
|
||||||
void sd_lld_start(SerialDriver *sdp) {
|
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
|
||||||
|
|
||||||
if (sdp->config == NULL)
|
if (config == NULL)
|
||||||
sdp->config = &default_config;
|
config = &default_config;
|
||||||
|
|
||||||
if (sdp->state == SD_STOP) {
|
if (sdp->state == SD_STOP) {
|
||||||
#if USE_LPC11xx_UART0
|
#if USE_LPC11xx_UART0
|
||||||
|
@ -257,7 +261,7 @@ void sd_lld_start(SerialDriver *sdp) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
uart_init(sdp);
|
uart_init(sdp, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -84,29 +84,29 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief UART0 driver enable switch.
|
* @brief UART0 driver enable switch.
|
||||||
* @details If set to @p TRUE the support for UART0 is included.
|
* @details If set to @p TRUE the support for UART0 is included.
|
||||||
* @note The default is @p TRUE .
|
* @note The default is @p TRUE .
|
||||||
*/
|
*/
|
||||||
#if !defined(USE_LPC11xx_UART0) || defined(__DOXYGEN__)
|
#if !defined(USE_LPC11xx_UART0) || defined(__DOXYGEN__)
|
||||||
#define USE_LPC11xx_UART0 TRUE
|
#define USE_LPC11xx_UART0 TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief FIFO preload parameter.
|
* @brief FIFO preload parameter.
|
||||||
* @details Configuration parameter, this values defines how many bytes are
|
* @details Configuration parameter, this values defines how many bytes are
|
||||||
* preloaded in the HW transmit FIFO for each interrupt, the maximum value is
|
* preloaded in the HW transmit FIFO for each interrupt, the maximum
|
||||||
* 16 the minimum is 1.
|
* value is 16 the minimum is 1.
|
||||||
* @note An high value reduces the number of interrupts generated but can
|
* @note An high value reduces the number of interrupts generated but can
|
||||||
* also increase the worst case interrupt response time because the
|
* also increase the worst case interrupt response time because the
|
||||||
* preload loops.
|
* preload loops.
|
||||||
*/
|
*/
|
||||||
#if !defined(LPC11xx_UART_FIFO_PRELOAD) || defined(__DOXYGEN__)
|
#if !defined(LPC11xx_UART_FIFO_PRELOAD) || defined(__DOXYGEN__)
|
||||||
#define LPC11xx_UART_FIFO_PRELOAD 16
|
#define LPC11xx_UART_FIFO_PRELOAD 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief UART0 interrupt priority level setting.
|
* @brief UART0 interrupt priority level setting.
|
||||||
*/
|
*/
|
||||||
#if !defined(LPC11xx_UART0_PRIORITY) || defined(__DOXYGEN__)
|
#if !defined(LPC11xx_UART0_PRIORITY) || defined(__DOXYGEN__)
|
||||||
#define LPC11xx_UART0_PRIORITY 3
|
#define LPC11xx_UART0_PRIORITY 3
|
||||||
|
@ -117,7 +117,7 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
#if (LPC11xx_UART_FIFO_PRELOAD < 1) || (LPC11xx_UART_FIFO_PRELOAD > 16)
|
#if (LPC11xx_UART_FIFO_PRELOAD < 1) || (LPC11xx_UART_FIFO_PRELOAD > 16)
|
||||||
#error "invalid LPC214x_UART_FIFO_PRELOAD setting"
|
#error "invalid LPC11xx_UART_FIFO_PRELOAD setting"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -130,7 +130,7 @@
|
||||||
typedef uint32_t sdflags_t;
|
typedef uint32_t sdflags_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief LPC214x Serial Driver configuration structure.
|
* @brief LPC11xx Serial Driver configuration structure.
|
||||||
* @details An instance of this structure must be passed to @p sdStart()
|
* @details An instance of this structure must be passed to @p sdStart()
|
||||||
* in order to configure and start a serial driver operations.
|
* in order to configure and start a serial driver operations.
|
||||||
*/
|
*/
|
||||||
|
@ -156,8 +156,6 @@ typedef struct {
|
||||||
_base_asynchronous_channel_data \
|
_base_asynchronous_channel_data \
|
||||||
/* Driver state.*/ \
|
/* Driver state.*/ \
|
||||||
sdstate_t state; \
|
sdstate_t state; \
|
||||||
/* Current configuration data.*/ \
|
|
||||||
const SerialConfig *config; \
|
|
||||||
/* Input queue.*/ \
|
/* Input queue.*/ \
|
||||||
InputQueue iqueue; \
|
InputQueue iqueue; \
|
||||||
/* Output queue.*/ \
|
/* Output queue.*/ \
|
||||||
|
@ -190,7 +188,7 @@ extern SerialDriver SD1;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
void sd_lld_init(void);
|
void sd_lld_init(void);
|
||||||
void sd_lld_start(SerialDriver *sdp);
|
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config);
|
||||||
void sd_lld_stop(SerialDriver *sdp);
|
void sd_lld_stop(SerialDriver *sdp);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,16 +58,17 @@ static const SerialConfig default_config = {
|
||||||
* @brief UART initialization.
|
* @brief UART initialization.
|
||||||
*
|
*
|
||||||
* @param[in] sdp communication channel associated to the UART
|
* @param[in] sdp communication channel associated to the UART
|
||||||
|
* @param[in] config the architecture-dependent serial driver configuration
|
||||||
*/
|
*/
|
||||||
static void uart_init(SerialDriver *sdp) {
|
static void uart_init(SerialDriver *sdp, const SerialConfig *config) {
|
||||||
LPC_UART_TypeDef *u = sdp->uart;
|
LPC_UART_TypeDef *u = sdp->uart;
|
||||||
|
|
||||||
uint32_t div = LPC13xx_UART_PCLK / (sdp->config->sc_speed << 4);
|
uint32_t div = LPC13xx_UART_PCLK / (config->sc_speed << 4);
|
||||||
u->LCR = sdp->config->sc_lcr | LCR_DLAB;
|
u->LCR = config->sc_lcr | LCR_DLAB;
|
||||||
u->DLL = div;
|
u->DLL = div;
|
||||||
u->DLM = div >> 8;
|
u->DLM = div >> 8;
|
||||||
u->LCR = sdp->config->sc_lcr;
|
u->LCR = config->sc_lcr;
|
||||||
u->FCR = FCR_ENABLE | FCR_RXRESET | FCR_TXRESET | sdp->config->sc_fcr;
|
u->FCR = FCR_ENABLE | FCR_RXRESET | FCR_TXRESET | config->sc_fcr;
|
||||||
u->ACR = 0;
|
u->ACR = 0;
|
||||||
u->FDR = 0x10;
|
u->FDR = 0x10;
|
||||||
u->TER = TER_ENABLE;
|
u->TER = TER_ENABLE;
|
||||||
|
@ -242,11 +243,14 @@ void sd_lld_init(void) {
|
||||||
* @brief Low level serial driver configuration and (re)start.
|
* @brief Low level serial driver configuration and (re)start.
|
||||||
*
|
*
|
||||||
* @param[in] sdp pointer to a @p SerialDriver object
|
* @param[in] sdp pointer to a @p SerialDriver object
|
||||||
|
* @param[in] config the architecture-dependent serial driver configuration.
|
||||||
|
* If this parameter is set to @p NULL then a default
|
||||||
|
* configuration is used.
|
||||||
*/
|
*/
|
||||||
void sd_lld_start(SerialDriver *sdp) {
|
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
|
||||||
|
|
||||||
if (sdp->config == NULL)
|
if (config == NULL)
|
||||||
sdp->config = &default_config;
|
config = &default_config;
|
||||||
|
|
||||||
if (sdp->state == SD_STOP) {
|
if (sdp->state == SD_STOP) {
|
||||||
#if USE_LPC13xx_UART0
|
#if USE_LPC13xx_UART0
|
||||||
|
@ -257,7 +261,7 @@ void sd_lld_start(SerialDriver *sdp) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
uart_init(sdp);
|
uart_init(sdp, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -84,29 +84,29 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief UART0 driver enable switch.
|
* @brief UART0 driver enable switch.
|
||||||
* @details If set to @p TRUE the support for UART0 is included.
|
* @details If set to @p TRUE the support for UART0 is included.
|
||||||
* @note The default is @p TRUE .
|
* @note The default is @p TRUE .
|
||||||
*/
|
*/
|
||||||
#if !defined(USE_LPC13xx_UART0) || defined(__DOXYGEN__)
|
#if !defined(USE_LPC13xx_UART0) || defined(__DOXYGEN__)
|
||||||
#define USE_LPC13xx_UART0 TRUE
|
#define USE_LPC13xx_UART0 TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief FIFO preload parameter.
|
* @brief FIFO preload parameter.
|
||||||
* @details Configuration parameter, this values defines how many bytes are
|
* @details Configuration parameter, this values defines how many bytes are
|
||||||
* preloaded in the HW transmit FIFO for each interrupt, the maximum value is
|
* preloaded in the HW transmit FIFO for each interrupt, the maximum
|
||||||
* 16 the minimum is 1.
|
* value is 16 the minimum is 1.
|
||||||
* @note An high value reduces the number of interrupts generated but can
|
* @note An high value reduces the number of interrupts generated but can
|
||||||
* also increase the worst case interrupt response time because the
|
* also increase the worst case interrupt response time because the
|
||||||
* preload loops.
|
* preload loops.
|
||||||
*/
|
*/
|
||||||
#if !defined(LPC13xx_UART_FIFO_PRELOAD) || defined(__DOXYGEN__)
|
#if !defined(LPC13xx_UART_FIFO_PRELOAD) || defined(__DOXYGEN__)
|
||||||
#define LPC13xx_UART_FIFO_PRELOAD 16
|
#define LPC13xx_UART_FIFO_PRELOAD 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief UART0 interrupt priority level setting.
|
* @brief UART0 interrupt priority level setting.
|
||||||
*/
|
*/
|
||||||
#if !defined(LPC13xx_UART0_PRIORITY) || defined(__DOXYGEN__)
|
#if !defined(LPC13xx_UART0_PRIORITY) || defined(__DOXYGEN__)
|
||||||
#define LPC13xx_UART0_PRIORITY 3
|
#define LPC13xx_UART0_PRIORITY 3
|
||||||
|
@ -117,7 +117,7 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
#if (LPC13xx_UART_FIFO_PRELOAD < 1) || (LPC13xx_UART_FIFO_PRELOAD > 16)
|
#if (LPC13xx_UART_FIFO_PRELOAD < 1) || (LPC13xx_UART_FIFO_PRELOAD > 16)
|
||||||
#error "invalid LPC214x_UART_FIFO_PRELOAD setting"
|
#error "invalid LPC13xx_UART_FIFO_PRELOAD setting"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -125,12 +125,12 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Serial Driver condition flags type.
|
* @brief Serial Driver condition flags type.
|
||||||
*/
|
*/
|
||||||
typedef uint32_t sdflags_t;
|
typedef uint32_t sdflags_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief LPC214x Serial Driver configuration structure.
|
* @brief LPC13xx Serial Driver configuration structure.
|
||||||
* @details An instance of this structure must be passed to @p sdStart()
|
* @details An instance of this structure must be passed to @p sdStart()
|
||||||
* in order to configure and start a serial driver operations.
|
* in order to configure and start a serial driver operations.
|
||||||
*/
|
*/
|
||||||
|
@ -156,8 +156,6 @@ typedef struct {
|
||||||
_base_asynchronous_channel_data \
|
_base_asynchronous_channel_data \
|
||||||
/* Driver state.*/ \
|
/* Driver state.*/ \
|
||||||
sdstate_t state; \
|
sdstate_t state; \
|
||||||
/* Current configuration data.*/ \
|
|
||||||
const SerialConfig *config; \
|
|
||||||
/* Input queue.*/ \
|
/* Input queue.*/ \
|
||||||
InputQueue iqueue; \
|
InputQueue iqueue; \
|
||||||
/* Output queue.*/ \
|
/* Output queue.*/ \
|
||||||
|
@ -190,7 +188,7 @@ extern SerialDriver SD1;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
void sd_lld_init(void);
|
void sd_lld_init(void);
|
||||||
void sd_lld_start(SerialDriver *sdp);
|
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config);
|
||||||
void sd_lld_stop(SerialDriver *sdp);
|
void sd_lld_stop(SerialDriver *sdp);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file MSP430/serial_lld.c
|
* @file MSP430/serial_lld.c
|
||||||
* @brief MSP430 low level serial driver code.
|
* @brief MSP430 low level serial driver code.
|
||||||
|
*
|
||||||
* @addtogroup MSP430_SERIAL
|
* @addtogroup MSP430_SERIAL
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
@ -88,9 +89,9 @@ static void notify1(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART0 initialization.
|
* @brief USART0 initialization.
|
||||||
*
|
*
|
||||||
* @param[in] config the architecture-dependent serial driver configuration
|
* @param[in] config the architecture-dependent serial driver configuration
|
||||||
*/
|
*/
|
||||||
static void usart0_init(const SerialConfig *config) {
|
static void usart0_init(const SerialConfig *config) {
|
||||||
|
|
||||||
|
@ -110,7 +111,7 @@ static void usart0_init(const SerialConfig *config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART0 de-initialization.
|
* @brief USART0 de-initialization.
|
||||||
*/
|
*/
|
||||||
static void usart0_deinit(void) {
|
static void usart0_deinit(void) {
|
||||||
|
|
||||||
|
@ -132,9 +133,9 @@ static void notify2(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART1 initialization.
|
* @brief USART1 initialization.
|
||||||
*
|
*
|
||||||
* @param[in] config the architecture-dependent serial driver configuration
|
* @param[in] config the architecture-dependent serial driver configuration
|
||||||
*/
|
*/
|
||||||
static void usart1_init(const SerialConfig *config) {
|
static void usart1_init(const SerialConfig *config) {
|
||||||
|
|
||||||
|
@ -154,7 +155,7 @@ static void usart1_init(const SerialConfig *config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART1 de-initialization.
|
* @brief USART1 de-initialization.
|
||||||
*/
|
*/
|
||||||
static void usart1_deinit(void) {
|
static void usart1_deinit(void) {
|
||||||
|
|
||||||
|
@ -236,7 +237,7 @@ CH_IRQ_HANDLER(USART1RX_VECTOR) {
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Low level serial driver initialization.
|
* @brief Low level serial driver initialization.
|
||||||
*/
|
*/
|
||||||
void sd_lld_init(void) {
|
void sd_lld_init(void) {
|
||||||
|
|
||||||
|
@ -254,11 +255,14 @@ void sd_lld_init(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Low level serial driver configuration and (re)start.
|
* @brief Low level serial driver configuration and (re)start.
|
||||||
*
|
*
|
||||||
* @param[in] sdp pointer to a @p SerialDriver object
|
* @param[in] sdp pointer to a @p SerialDriver object
|
||||||
|
* @param[in] config the architecture-dependent serial driver configuration.
|
||||||
|
* If this parameter is set to @p NULL then a default
|
||||||
|
* configuration is used.
|
||||||
*/
|
*/
|
||||||
void sd_lld_start(SerialDriver *sdp) {
|
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
|
||||||
|
|
||||||
if (sdp->config == NULL)
|
if (sdp->config == NULL)
|
||||||
sdp->config = &default_config;
|
sdp->config = &default_config;
|
||||||
|
@ -278,11 +282,11 @@ void sd_lld_start(SerialDriver *sdp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Low level serial driver stop.
|
* @brief Low level serial driver stop.
|
||||||
* @details De-initializes the USART, stops the associated clock, resets the
|
* @details De-initializes the USART, stops the associated clock, resets the
|
||||||
* interrupt vector.
|
* interrupt vector.
|
||||||
*
|
*
|
||||||
* @param[in] sdp pointer to a @p SerialDriver object
|
* @param[in] sdp pointer to a @p SerialDriver object
|
||||||
*/
|
*/
|
||||||
void sd_lld_stop(SerialDriver *sdp) {
|
void sd_lld_stop(SerialDriver *sdp) {
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file MSP430/serial_lld.h
|
* @file MSP430/serial_lld.h
|
||||||
* @brief MSP430 low level serial driver header.
|
* @brief MSP430 low level serial driver header.
|
||||||
|
*
|
||||||
* @addtogroup MSP430_SERIAL
|
* @addtogroup MSP430_SERIAL
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
@ -38,18 +39,18 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART0 driver enable switch.
|
* @brief USART0 driver enable switch.
|
||||||
* @details If set to @p TRUE the support for USART0 is included.
|
* @details If set to @p TRUE the support for USART0 is included.
|
||||||
* @note The default is @p TRUE.
|
* @note The default is @p TRUE.
|
||||||
*/
|
*/
|
||||||
#if !defined(USE_MSP430_USART0) || defined(__DOXYGEN__)
|
#if !defined(USE_MSP430_USART0) || defined(__DOXYGEN__)
|
||||||
#define USE_MSP430_USART0 TRUE
|
#define USE_MSP430_USART0 TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief USART1 driver enable switch.
|
* @brief USART1 driver enable switch.
|
||||||
* @details If set to @p TRUE the support for USART1 is included.
|
* @details If set to @p TRUE the support for USART1 is included.
|
||||||
* @note The default is @p FALSE.
|
* @note The default is @p FALSE.
|
||||||
*/
|
*/
|
||||||
#if !defined(USE_MSP430_USART1) || defined(__DOXYGEN__)
|
#if !defined(USE_MSP430_USART1) || defined(__DOXYGEN__)
|
||||||
#define USE_MSP430_USART1 TRUE
|
#define USE_MSP430_USART1 TRUE
|
||||||
|
@ -64,12 +65,12 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serial Driver condition flags type.
|
* @brief Serial Driver condition flags type.
|
||||||
*/
|
*/
|
||||||
typedef uint8_t sdflags_t;
|
typedef uint8_t sdflags_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief MSP430 Serial Driver configuration structure.
|
* @brief MSP430 Serial Driver configuration structure.
|
||||||
* @details An instance of this structure must be passed to @p sdStart()
|
* @details An instance of this structure must be passed to @p sdStart()
|
||||||
* in order to configure and start a serial driver operations.
|
* in order to configure and start a serial driver operations.
|
||||||
*/
|
*/
|
||||||
|
@ -95,8 +96,6 @@ typedef struct {
|
||||||
_base_asynchronous_channel_data \
|
_base_asynchronous_channel_data \
|
||||||
/* Driver state.*/ \
|
/* Driver state.*/ \
|
||||||
sdstate_t state; \
|
sdstate_t state; \
|
||||||
/* Current configuration data.*/ \
|
|
||||||
const SerialConfig *config; \
|
|
||||||
/* Input queue.*/ \
|
/* Input queue.*/ \
|
||||||
InputQueue iqueue; \
|
InputQueue iqueue; \
|
||||||
/* Output queue.*/ \
|
/* Output queue.*/ \
|
||||||
|
@ -116,8 +115,8 @@ typedef struct {
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Macro for baud rate computation.
|
* @brief Macro for baud rate computation.
|
||||||
* @note Make sure the final baud rate is within tolerance.
|
* @note Make sure the final baud rate is within tolerance.
|
||||||
*/
|
*/
|
||||||
#define UBR(b) (SMCLK / (b))
|
#define UBR(b) (SMCLK / (b))
|
||||||
|
|
||||||
|
@ -136,7 +135,7 @@ extern SerialDriver SD2;
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
void sd_lld_init(void);
|
void sd_lld_init(void);
|
||||||
void sd_lld_start(SerialDriver *sdp);
|
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config);
|
||||||
void sd_lld_stop(SerialDriver *sdp);
|
void sd_lld_stop(SerialDriver *sdp);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ static bool_t outint(SerialDriver *sdp) {
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Low level serial driver initialization.
|
* @brief Low level serial driver initialization.
|
||||||
*/
|
*/
|
||||||
void sd_lld_init(void) {
|
void sd_lld_init(void) {
|
||||||
|
|
||||||
|
@ -222,9 +222,9 @@ void sd_lld_init(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Low level serial driver configuration and (re)start.
|
* @brief Low level serial driver configuration and (re)start.
|
||||||
*
|
*
|
||||||
* @param[in] sdp pointer to a @p SerialDriver object
|
* @param[in] sdp pointer to a @p SerialDriver object
|
||||||
*/
|
*/
|
||||||
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
|
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
|
||||||
|
|
||||||
|
@ -243,11 +243,11 @@ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Low level serial driver stop.
|
* @brief Low level serial driver stop.
|
||||||
* @details De-initializes the USART, stops the associated clock, resets the
|
* @details De-initializes the USART, stops the associated clock, resets the
|
||||||
* interrupt vector.
|
* interrupt vector.
|
||||||
*
|
*
|
||||||
* @param[in] sdp pointer to a @p SerialDriver object
|
* @param[in] sdp pointer to a @p SerialDriver object
|
||||||
*/
|
*/
|
||||||
void sd_lld_stop(SerialDriver *sdp) {
|
void sd_lld_stop(SerialDriver *sdp) {
|
||||||
|
|
||||||
|
|
|
@ -39,41 +39,41 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Serial buffers size.
|
* @brief Serial buffers size.
|
||||||
* @details Configuration parameter, you can change the depth of the queue
|
* @details Configuration parameter, you can change the depth of the queue
|
||||||
* buffers depending on the requirements of your application.
|
* buffers depending on the requirements of your application.
|
||||||
*/
|
*/
|
||||||
#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
|
#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
|
||||||
#define SERIAL_BUFFERS_SIZE 1024
|
#define SERIAL_BUFFERS_SIZE 1024
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SD1 driver enable switch.
|
* @brief SD1 driver enable switch.
|
||||||
* @details If set to @p TRUE the support for SD1 is included.
|
* @details If set to @p TRUE the support for SD1 is included.
|
||||||
* @note The default is @p TRUE.
|
* @note The default is @p TRUE.
|
||||||
*/
|
*/
|
||||||
#if !defined(USE_SIM_SERIAL1) || defined(__DOXYGEN__)
|
#if !defined(USE_SIM_SERIAL1) || defined(__DOXYGEN__)
|
||||||
#define USE_SIM_SERIAL1 TRUE
|
#define USE_SIM_SERIAL1 TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SD2 driver enable switch.
|
* @brief SD2 driver enable switch.
|
||||||
* @details If set to @p TRUE the support for SD2 is included.
|
* @details If set to @p TRUE the support for SD2 is included.
|
||||||
* @note The default is @p TRUE.
|
* @note The default is @p TRUE.
|
||||||
*/
|
*/
|
||||||
#if !defined(USE_SIM_SERIAL2) || defined(__DOXYGEN__)
|
#if !defined(USE_SIM_SERIAL2) || defined(__DOXYGEN__)
|
||||||
#define USE_SIM_SERIAL2 TRUE
|
#define USE_SIM_SERIAL2 TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Listen port for SD1.
|
* @brief Listen port for SD1.
|
||||||
*/
|
*/
|
||||||
#if !defined(SD1_PORT) || defined(__DOXYGEN__)
|
#if !defined(SD1_PORT) || defined(__DOXYGEN__)
|
||||||
#define SIM_SD1_PORT 29001
|
#define SIM_SD1_PORT 29001
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Listen port for SD2.
|
* @brief Listen port for SD2.
|
||||||
*/
|
*/
|
||||||
#if !defined(SD2_PORT) || defined(__DOXYGEN__)
|
#if !defined(SD2_PORT) || defined(__DOXYGEN__)
|
||||||
#define SIM_SD2_PORT 29002
|
#define SIM_SD2_PORT 29002
|
||||||
|
@ -88,24 +88,23 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serial Driver condition flags type.
|
* @brief Serial Driver condition flags type.
|
||||||
*/
|
*/
|
||||||
typedef uint32_t sdflags_t;
|
typedef uint32_t sdflags_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Generic Serial Driver configuration structure.
|
* @brief Generic Serial Driver configuration structure.
|
||||||
* @details An instance of this structure must be passed to @p sdStart()
|
* @details An instance of this structure must be passed to @p sdStart()
|
||||||
* in order to configure and start a serial driver operations.
|
* in order to configure and start a serial driver operations.
|
||||||
*
|
* @note This structure content is architecture dependent, each driver
|
||||||
* @note This structure content is architecture dependent, each driver
|
* implementation defines its own version and the custom static
|
||||||
* implementation defines its own version and the custom static
|
* initializers.
|
||||||
* initializers.
|
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
} SerialConfig;
|
} SerialConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief @p SerialDriver specific data.
|
* @brief @p SerialDriver specific data.
|
||||||
*/
|
*/
|
||||||
#define _serial_driver_data \
|
#define _serial_driver_data \
|
||||||
_base_asynchronous_channel_data \
|
_base_asynchronous_channel_data \
|
||||||
|
|
|
@ -111,7 +111,7 @@ typedef struct {
|
||||||
} SerialConfig;
|
} SerialConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief @p SerialDriver specific data.
|
* @brief @p SerialDriver specific data.
|
||||||
*/
|
*/
|
||||||
#define _serial_driver_data \
|
#define _serial_driver_data \
|
||||||
_base_asynchronous_channel_data \
|
_base_asynchronous_channel_data \
|
||||||
|
|
|
@ -37,10 +37,10 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief PAL setup.
|
* @brief PAL setup.
|
||||||
* @details Digital I/O ports static configuration as defined in @p board.h.
|
* @details Digital I/O ports static configuration as defined in @p board.h.
|
||||||
*/
|
*/
|
||||||
const STM8GPIOConfig pal_default_config =
|
ROMCONST STM8GPIOConfig pal_default_config =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
{VAL_GPIOAODR, 0, VAL_GPIOADDR, VAL_GPIOACR1, VAL_GPIOACR2},
|
{VAL_GPIOAODR, 0, VAL_GPIOADDR, VAL_GPIOACR1, VAL_GPIOACR2},
|
||||||
|
@ -78,7 +78,7 @@ void hal_lld_init(void) {
|
||||||
while ((CLK_ICKR & 2) == 0) /* HSIRDY */
|
while ((CLK_ICKR & 2) == 0) /* HSIRDY */
|
||||||
;
|
;
|
||||||
#elif STM8_CLOCK_SOURCE == CLK_SOURCE_LSI
|
#elif STM8_CLOCK_SOURCE == CLK_SOURCE_LSI
|
||||||
CLK_ICKR = 8; /* LSIEN */
|
CLK_ICKR = 8; /* LSIEN */
|
||||||
while ((CLK_ICKR & 16) == 0) /* LSIRDY */
|
while ((CLK_ICKR & 16) == 0) /* LSIRDY */
|
||||||
;
|
;
|
||||||
#else /* STM8_CLOCK_SOURCE == CLK_SOURCE_HSE */
|
#else /* STM8_CLOCK_SOURCE == CLK_SOURCE_HSE */
|
||||||
|
@ -100,7 +100,7 @@ void hal_lld_init(void) {
|
||||||
/* Clocks initially all disabled.*/
|
/* Clocks initially all disabled.*/
|
||||||
CLK_PCKENR1 = 0;
|
CLK_PCKENR1 = 0;
|
||||||
CLK_PCKENR2 = 0;
|
CLK_PCKENR2 = 0;
|
||||||
|
|
||||||
/* Other clock related initializations.*/
|
/* Other clock related initializations.*/
|
||||||
CLK_CSSR = 0;
|
CLK_CSSR = 0;
|
||||||
CLK_CCOR = 0;
|
CLK_CCOR = 0;
|
||||||
|
|
|
@ -66,21 +66,21 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clock source setting.
|
* @brief Clock source setting.
|
||||||
*/
|
*/
|
||||||
#if !defined(STM8_CLOCK_SOURCE) || defined(__DOXYGEN__)
|
#if !defined(STM8_CLOCK_SOURCE) || defined(__DOXYGEN__)
|
||||||
#define STM8_CLOCK_SOURCE CLK_SOURCE_DEFAULT
|
#define STM8_CLOCK_SOURCE CLK_SOURCE_DEFAULT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief HSI clock divider.
|
* @brief HSI clock divider.
|
||||||
*/
|
*/
|
||||||
#if !defined(STM8_HSI_DIVIDER) || defined(__DOXYGEN__)
|
#if !defined(STM8_HSI_DIVIDER) || defined(__DOXYGEN__)
|
||||||
#define STM8_HSI_DIVIDER CLK_HSI_DIV8
|
#define STM8_HSI_DIVIDER CLK_HSI_DIV8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CPU clock divider.
|
* @brief CPU clock divider.
|
||||||
*/
|
*/
|
||||||
#if !defined(STM8_CPU_DIVIDER) || defined(__DOXYGEN__)
|
#if !defined(STM8_CPU_DIVIDER) || defined(__DOXYGEN__)
|
||||||
#define STM8_CPU_DIVIDER CLK_CPU_DIV1
|
#define STM8_CPU_DIVIDER CLK_CPU_DIV1
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
/* I/O Ports Types and constants. */
|
/* I/O Ports Types and constants. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief GPIO port representation.
|
||||||
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
volatile uint8_t ODR;
|
volatile uint8_t ODR;
|
||||||
volatile uint8_t IDR;
|
volatile uint8_t IDR;
|
||||||
|
@ -191,7 +194,7 @@ typedef gpio_t *ioportid_t;
|
||||||
*/
|
*/
|
||||||
#define pal_lld_setgroupmode(port, mask, mode) ((void)(mode))
|
#define pal_lld_setgroupmode(port, mask, mode) ((void)(mode))
|
||||||
|
|
||||||
extern const STM8GPIOConfig pal_default_config;
|
extern ROMCONST STM8GPIOConfig pal_default_config;
|
||||||
|
|
||||||
#endif /* CH_HAL_USE_PAL */
|
#endif /* CH_HAL_USE_PAL */
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ SerialDriver SD3;
|
||||||
/**
|
/**
|
||||||
* @brief Driver default configuration.
|
* @brief Driver default configuration.
|
||||||
*/
|
*/
|
||||||
static const SerialConfig default_config = {
|
static ROMCONST SerialConfig default_config = {
|
||||||
BBR(SERIAL_DEFAULT_BITRATE),
|
BBR(SERIAL_DEFAULT_BITRATE),
|
||||||
SD_MODE_PARITY_NONE | SD_MODE_STOP_1
|
SD_MODE_PARITY_NONE | SD_MODE_STOP_1
|
||||||
};
|
};
|
||||||
|
|
|
@ -67,6 +67,9 @@ void sd_lld_init(void) {
|
||||||
* @brief Low level serial driver configuration and (re)start.
|
* @brief Low level serial driver configuration and (re)start.
|
||||||
*
|
*
|
||||||
* @param[in] sdp pointer to a @p SerialDriver object
|
* @param[in] sdp pointer to a @p SerialDriver object
|
||||||
|
* @param[in] config the architecture-dependent serial driver configuration.
|
||||||
|
* If this parameter is set to @p NULL then a default
|
||||||
|
* configuration is used.
|
||||||
*/
|
*/
|
||||||
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
|
void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,19 @@ typedef int32_t cnt_t;
|
||||||
*/
|
*/
|
||||||
#define INLINE inline
|
#define INLINE inline
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ROM constant modifier.
|
||||||
|
* @note This is required because some compilers require a custom keyword,
|
||||||
|
* usually this macro is just set to "const" for the GCC compiler.
|
||||||
|
* @note This macro is not used to place constants in different address
|
||||||
|
* spaces (like AVR requires as example) because it is assumed that
|
||||||
|
* a pointer to a ROMCONST constant is compatible with a pointer
|
||||||
|
* to a normal variable. It is just like the "const" keyword but
|
||||||
|
* requires that the constant is placed in ROM if the architecture
|
||||||
|
* supports it.
|
||||||
|
*/
|
||||||
|
#define ROMCONST const
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Packed structure modifier (within).
|
* @brief Packed structure modifier (within).
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file ARM7/chtypes.h
|
* @file ARM7/chtypes.h
|
||||||
* @brief ARM7 architecture port system types.
|
* @brief ARM7 architecture port system types.
|
||||||
|
*
|
||||||
* @addtogroup ARM7_CORE
|
* @addtogroup ARM7_CORE
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
@ -47,9 +48,33 @@ typedef uint32_t eventmask_t; /**< Events mask. */
|
||||||
typedef uint32_t systime_t; /**< System time. */
|
typedef uint32_t systime_t; /**< System time. */
|
||||||
typedef int32_t cnt_t; /**< Resources counter. */
|
typedef int32_t cnt_t; /**< Resources counter. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Inline function modifier.
|
||||||
|
*/
|
||||||
#define INLINE inline
|
#define INLINE inline
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ROM constant modifier.
|
||||||
|
* @note It is set to use the "const" keyword in this port.
|
||||||
|
*/
|
||||||
|
#define ROMCONST const
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (within).
|
||||||
|
* @note It uses the "packed" GCC attribute.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (before).
|
||||||
|
* @note Empty in this port.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_BEGIN
|
#define PACK_STRUCT_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (after).
|
||||||
|
* @note Empty in this port.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_END
|
#define PACK_STRUCT_END
|
||||||
|
|
||||||
#endif /* _CHTYPES_H_ */
|
#endif /* _CHTYPES_H_ */
|
||||||
|
|
|
@ -46,9 +46,33 @@ typedef uint32_t eventmask_t; /**< Events mask. */
|
||||||
typedef uint32_t systime_t; /**< System time. */
|
typedef uint32_t systime_t; /**< System time. */
|
||||||
typedef int32_t cnt_t; /**< Resources counter. */
|
typedef int32_t cnt_t; /**< Resources counter. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Inline function modifier.
|
||||||
|
*/
|
||||||
#define INLINE inline
|
#define INLINE inline
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ROM constant modifier.
|
||||||
|
* @note It is set to use the "const" keyword in this port.
|
||||||
|
*/
|
||||||
|
#define ROMCONST const
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (within).
|
||||||
|
* @note It uses the "packed" GCC attribute.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (before).
|
||||||
|
* @note Empty in this port.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_BEGIN
|
#define PACK_STRUCT_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (after).
|
||||||
|
* @note Empty in this port.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_END
|
#define PACK_STRUCT_END
|
||||||
|
|
||||||
#endif /* _CHTYPES_H_ */
|
#endif /* _CHTYPES_H_ */
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file AVR/chtypes.h
|
* @file AVR/chtypes.h
|
||||||
* @brief AVR architecture port system types.
|
* @brief AVR architecture port system types.
|
||||||
|
*
|
||||||
* @addtogroup AVR_CORE
|
* @addtogroup AVR_CORE
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
@ -47,9 +48,33 @@ typedef uint8_t eventmask_t; /**< Events mask. */
|
||||||
typedef uint16_t systime_t; /**< System time. */
|
typedef uint16_t systime_t; /**< System time. */
|
||||||
typedef int8_t cnt_t; /**< Resources counter. */
|
typedef int8_t cnt_t; /**< Resources counter. */
|
||||||
|
|
||||||
#define INLINE inline
|
/**
|
||||||
|
* @brief Inline function modifier.
|
||||||
|
*/
|
||||||
|
#define INLINE inline
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ROM constant modifier.
|
||||||
|
* @note It is set to use the "const" keyword in this port.
|
||||||
|
*/
|
||||||
|
#define ROMCONST const
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (within).
|
||||||
|
* @note It uses the "packed" GCC attribute.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (before).
|
||||||
|
* @note Empty in this port.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_BEGIN
|
#define PACK_STRUCT_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (after).
|
||||||
|
* @note Empty in this port.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_END
|
#define PACK_STRUCT_END
|
||||||
|
|
||||||
#endif /* _CHTYPES_H_ */
|
#endif /* _CHTYPES_H_ */
|
||||||
|
|
|
@ -18,8 +18,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file MSP430/chtypes.h
|
* @file MSP430/chtypes.h
|
||||||
* @brief MSP430 architecture port system types.
|
* @brief MSP430 architecture port system types.
|
||||||
|
*
|
||||||
* @addtogroup MSP430_CORE
|
* @addtogroup MSP430_CORE
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
@ -47,9 +48,33 @@ typedef uint16_t eventmask_t; /**< Events mask. */
|
||||||
typedef uint16_t systime_t; /**< System time. */
|
typedef uint16_t systime_t; /**< System time. */
|
||||||
typedef int16_t cnt_t; /**< Resources counter. */
|
typedef int16_t cnt_t; /**< Resources counter. */
|
||||||
|
|
||||||
#define INLINE inline
|
/**
|
||||||
|
* @brief Inline function modifier.
|
||||||
|
*/
|
||||||
|
#define INLINE inline
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ROM constant modifier.
|
||||||
|
* @note It is set to use the "const" keyword in this port.
|
||||||
|
*/
|
||||||
|
#define ROMCONST const
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (within).
|
||||||
|
* @note It uses the "packed" GCC attribute.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (before).
|
||||||
|
* @note Empty in this port.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_BEGIN
|
#define PACK_STRUCT_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (after).
|
||||||
|
* @note Empty in this port.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_END
|
#define PACK_STRUCT_END
|
||||||
|
|
||||||
#endif /* _CHTYPES_H_ */
|
#endif /* _CHTYPES_H_ */
|
||||||
|
|
|
@ -60,16 +60,33 @@ typedef uint32_t eventmask_t; /**< Events mask. */
|
||||||
typedef uint32_t systime_t; /**< System time. */
|
typedef uint32_t systime_t; /**< System time. */
|
||||||
typedef int32_t cnt_t; /**< Resources counter. */
|
typedef int32_t cnt_t; /**< Resources counter. */
|
||||||
|
|
||||||
/** Inline function modifier. */
|
/**
|
||||||
#define INLINE inline
|
* @brief Inline function modifier.
|
||||||
|
*/
|
||||||
|
#define INLINE inline
|
||||||
|
|
||||||
/** Packed structure modifier (within). */
|
/**
|
||||||
|
* @brief ROM constant modifier.
|
||||||
|
* @note It is set to use the "const" keyword in this port.
|
||||||
|
*/
|
||||||
|
#define ROMCONST const
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (within).
|
||||||
|
* @note It uses the "packed" GCC attribute.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
||||||
|
|
||||||
/** Packed structure modifier (before). */
|
/**
|
||||||
|
* @brief Packed structure modifier (before).
|
||||||
|
* @note Empty in this port.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_BEGIN
|
#define PACK_STRUCT_BEGIN
|
||||||
|
|
||||||
/** Packed structure modifier (after). */
|
/**
|
||||||
|
* @brief Packed structure modifier (after).
|
||||||
|
* @note Empty in this port.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_END
|
#define PACK_STRUCT_END
|
||||||
|
|
||||||
#endif /* _CHTYPES_H_ */
|
#endif /* _CHTYPES_H_ */
|
||||||
|
|
|
@ -40,9 +40,33 @@ typedef uint32_t eventmask_t; /**< Events mask. */
|
||||||
typedef uint32_t systime_t; /**< System time. */
|
typedef uint32_t systime_t; /**< System time. */
|
||||||
typedef int32_t cnt_t; /**< Resources counter. */
|
typedef int32_t cnt_t; /**< Resources counter. */
|
||||||
|
|
||||||
#define INLINE inline
|
/**
|
||||||
|
* @brief Inline function modifier.
|
||||||
|
*/
|
||||||
|
#define INLINE inline
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ROM constant modifier.
|
||||||
|
* @note It is set to use the "const" keyword in this port.
|
||||||
|
*/
|
||||||
|
#define ROMCONST const
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (within).
|
||||||
|
* @note It uses the "packed" GCC attribute.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (before).
|
||||||
|
* @note Empty in this port.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_BEGIN
|
#define PACK_STRUCT_BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packed structure modifier (after).
|
||||||
|
* @note Empty in this port.
|
||||||
|
*/
|
||||||
#define PACK_STRUCT_END
|
#define PACK_STRUCT_END
|
||||||
|
|
||||||
#endif /* _CHTYPES_H_ */
|
#endif /* _CHTYPES_H_ */
|
||||||
|
|
|
@ -18,14 +18,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file templates/chtypes.h
|
* @file STM8/chtypes.h
|
||||||
* @brief System types template.
|
* @brief STM8 port system types.
|
||||||
* @details The types defined in this file may change depending on the target
|
|
||||||
* architecture. You may also try to optimize the size of the various
|
|
||||||
* types in order to privilege size or performance, be careful in
|
|
||||||
* doing so.
|
|
||||||
*
|
*
|
||||||
* @addtogroup types
|
* @addtogroup STM8_CORE
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -40,15 +36,15 @@
|
||||||
//#include <stdint.h>
|
//#include <stdint.h>
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t; /**< C99-style 8 bits unsigned. */
|
||||||
typedef signed char int8_t;
|
typedef signed char int8_t; /**< C99-style 8 bits signed. */
|
||||||
typedef unsigned int uint16_t;
|
typedef unsigned int uint16_t; /**< C99-style 16 bits unsigned. */
|
||||||
typedef signed int int16_t;
|
typedef signed int int16_t; /**< C99-style 16 bits signed. */
|
||||||
typedef unsigned long uint32_t;
|
typedef unsigned long uint32_t; /**< C99-style 32 bits unsigned. */
|
||||||
typedef signed long int32_t;
|
typedef signed long int32_t; /**< C99-style 32 bits signed. */
|
||||||
typedef uint8_t uint_fast8_t;
|
typedef uint8_t uint_fast8_t; /**< C99-style 8 bits unsigned. */
|
||||||
typedef uint16_t uint_fast16_t;
|
typedef uint16_t uint_fast16_t; /**< C99-style 16 bits unsigned. */
|
||||||
typedef uint32_t uint_fast32_t;
|
typedef uint32_t uint_fast32_t; /**< C99-style 32 bits unsigned. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Boolean, recommended the fastest signed.
|
* @brief Boolean, recommended the fastest signed.
|
||||||
|
@ -105,18 +101,27 @@ typedef int16_t cnt_t;
|
||||||
*/
|
*/
|
||||||
#define INLINE inline
|
#define INLINE inline
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief ROM constant modifier.
|
||||||
|
* @note Uses the custom "code" keyword in this port.
|
||||||
|
*/
|
||||||
|
#define ROMCONST code
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Packed structure modifier (within).
|
* @brief Packed structure modifier (within).
|
||||||
|
* @note Empty in this port.
|
||||||
*/
|
*/
|
||||||
#define PACK_STRUCT_STRUCT
|
#define PACK_STRUCT_STRUCT
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Packed structure modifier (before).
|
* @brief Packed structure modifier (before).
|
||||||
|
* @note Empty in this port.
|
||||||
*/
|
*/
|
||||||
#define PACK_STRUCT_BEGIN
|
#define PACK_STRUCT_BEGIN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Packed structure modifier (after).
|
* @brief Packed structure modifier (after).
|
||||||
|
* @note Empty in this port.
|
||||||
*/
|
*/
|
||||||
#define PACK_STRUCT_END
|
#define PACK_STRUCT_END
|
||||||
|
|
||||||
|
|
10
readme.txt
10
readme.txt
|
@ -59,7 +59,15 @@
|
||||||
*** 1.5.6 ***
|
*** 1.5.6 ***
|
||||||
- FIX: Fixed wrong macros in chioch.h (bug 2989468).
|
- FIX: Fixed wrong macros in chioch.h (bug 2989468).
|
||||||
- FIX: Fixed wrong macro check in serial.h (bug 2989459)(backported in 1.4.3).
|
- FIX: Fixed wrong macro check in serial.h (bug 2989459)(backported in 1.4.3).
|
||||||
- Various documentation fixes.
|
- NEW: Added a ROMCONST macro in chtypes.h, this macro must be used for
|
||||||
|
constant that must be placed in code space, it should not be assumed that
|
||||||
|
the "const" keyword does that. Note that this macro is not used to place
|
||||||
|
constants in different address spaces (AVR) because it is assumed that a
|
||||||
|
pointer to a ROMCONST variable is compatible with a normal pointer.
|
||||||
|
- OPT: Internal optimization in the serial driver, it now is a bit smaller
|
||||||
|
and uses less RAM (all architectures).
|
||||||
|
- Various documentation fixes, added an article covering debugging under
|
||||||
|
ChibiOS/RT.
|
||||||
|
|
||||||
*** 1.5.5 ***
|
*** 1.5.5 ***
|
||||||
- FIX: Removed some "dead" code in the old ARMv7-M files (there are new
|
- FIX: Removed some "dead" code in the old ARMv7-M files (there are new
|
||||||
|
|
Loading…
Reference in New Issue