-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08500ab
commit 600cbaf
Showing
54 changed files
with
8,440 additions
and
1,787 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+0 Bytes
(100%)
C_Course/USART/.metadata/.plugins/org.eclipse.cdt.core/Lesson_1.1441447662933.pdom
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
C_Course/USART/.metadata/.plugins/org.eclipse.cdt.core/Lesson_2.1441447662806.pdom
Binary file not shown.
Binary file modified
BIN
-2.8 MB
(0.14%)
C_Course/USART/.metadata/.plugins/org.eclipse.cdt.core/Lesson_2_P1.1442574569473.pdom
Binary file not shown.
4,331 changes: 4,331 additions & 0 deletions
4,331
C_Course/USART/.metadata/.plugins/org.eclipse.cdt.core/Lesson_2_P2.language.settings.xml
Large diffs are not rendered by default.
Oops, something went wrong.
12 changes: 8 additions & 4 deletions
12
C_Course/USART/.metadata/.plugins/org.eclipse.cdt.ui/Lesson_1.build.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
10:10:09 **** Clean-only build of configuration Debug for project Lesson_1 **** | ||
make clean | ||
rm -rf ./system/src/stm32f0-stdperiph/stm32f0xx_gpio.o ./system/src/stm32f0-stdperiph/stm32f0xx_rcc.o ./system/src/newlib/_cxx.o ./system/src/newlib/_exit.o ./system/src/newlib/_sbrk.o ./system/src/newlib/_startup.o ./system/src/newlib/_syscalls.o ./system/src/newlib/assert.o ./system/src/diag/Trace.o ./system/src/diag/trace_impl.o ./system/src/cortexm/_initialize_hardware.o ./system/src/cortexm/_reset_hardware.o ./system/src/cortexm/exception_handlers.o ./system/src/cmsis/system_stm32f0xx.o ./system/src/cmsis/vectors_stm32f0xx.o ./src/MCU/led.o ./src/MCU/tick.o ./src/MCU/usart2.o ./src/main.o Lesson_1.hex Lesson_1.siz ./system/src/stm32f0-stdperiph/stm32f0xx_gpio.d ./system/src/stm32f0-stdperiph/stm32f0xx_rcc.d ./system/src/newlib/_exit.d ./system/src/newlib/_sbrk.d ./system/src/newlib/_startup.d ./system/src/newlib/_syscalls.d ./system/src/newlib/assert.d ./system/src/diag/Trace.d ./system/src/diag/trace_impl.d ./system/src/cortexm/_initialize_hardware.d ./system/src/cortexm/_reset_hardware.d ./system/src/cortexm/exception_handlers.d ./system/src/cmsis/system_stm32f0xx.d ./system/src/cmsis/vectors_stm32f0xx.d ./src/MCU/led.d ./src/MCU/tick.d ./src/MCU/usart2.d ./src/main.d ./system/src/newlib/_cxx.d Lesson_1.elf | ||
14:04:37 **** Incremental Build of configuration Debug for project Lesson_1 **** | ||
make all | ||
Invoking: Cross ARM GNU Print Size | ||
arm-none-eabi-size --format=berkeley "Lesson_1.elf" | ||
text data bss dec hex filename | ||
4765 208 420 5393 1511 Lesson_1.elf | ||
Finished building: Lesson_1.siz | ||
|
||
|
||
10:10:09 Build Finished (took 100ms) | ||
14:04:37 Build Finished (took 164ms) | ||
|
45 changes: 3 additions & 42 deletions
45
C_Course/USART/.metadata/.plugins/org.eclipse.cdt.ui/Lesson_2.build.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,6 @@ | ||
11:04:45 **** Incremental Build of configuration Debug for project Lesson_2 **** | ||
13:44:55 **** Incremental Build of configuration Debug for project Lesson_2 **** | ||
make all | ||
Building file: ../src/MCU/usart2.c | ||
Invoking: Cross ARM C Compiler | ||
arm-none-eabi-gcc -mcpu=cortex-m0 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -Wall -Wextra -g3 -DDEBUG -DUSE_FULL_ASSERT -DTRACE -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F030 -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f0-stdperiph" -std=gnu11 -MMD -MP -MF"src/MCU/usart2.d" -MT"src/MCU/usart2.o" -c -o "src/MCU/usart2.o" "../src/MCU/usart2.c" | ||
../src/MCU/usart2.c: In function 'Setbaudrate': | ||
../src/MCU/usart2.c:39:34: warning: unused parameter 'baud' [-Wunused-parameter] | ||
static void Setbaudrate(uint32_t baud) | ||
^ | ||
../src/MCU/usart2.c: In function 'SendByte': | ||
../src/MCU/usart2.c:107:38: warning: unused parameter 'source' [-Wunused-parameter] | ||
static uint_fast8_t SendByte(uint8_t source) | ||
^ | ||
../src/MCU/usart2.c: In function 'GetByte': | ||
../src/MCU/usart2.c:133:37: warning: unused parameter 'destination' [-Wunused-parameter] | ||
static int_fast8_t GetByte(uint8_t *destination) | ||
^ | ||
../src/MCU/usart2.c: At top level: | ||
../src/MCU/usart2.c:51:21: warning: 'IsWriteBusy' defined but not used [-Wunused-function] | ||
static uint_fast8_t IsWriteBusy(void) | ||
^ | ||
Finished building: ../src/MCU/usart2.c | ||
|
||
Building target: Lesson_2.elf | ||
Invoking: Cross ARM C++ Linker | ||
arm-none-eabi-g++ -mcpu=cortex-m0 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -Wall -Wextra -g3 -T mem.ld -T libs.ld -T sections.ld -nostartfiles -Xlinker --gc-sections -L"../ldscripts" -Wl,-Map,"Lesson_2.map" --specs=nano.specs -o "Lesson_2.elf" ./system/src/stm32f0-stdperiph/stm32f0xx_gpio.o ./system/src/stm32f0-stdperiph/stm32f0xx_rcc.o ./system/src/newlib/_cxx.o ./system/src/newlib/_exit.o ./system/src/newlib/_sbrk.o ./system/src/newlib/_startup.o ./system/src/newlib/_syscalls.o ./system/src/newlib/assert.o ./system/src/diag/Trace.o ./system/src/diag/trace_impl.o ./system/src/cortexm/_initialize_hardware.o ./system/src/cortexm/_reset_hardware.o ./system/src/cortexm/exception_handlers.o ./system/src/cmsis/system_stm32f0xx.o ./system/src/cmsis/vectors_stm32f0xx.o ./src/MCU/led.o ./src/MCU/tick.o ./src/MCU/usart2.o ./src/main.o | ||
Finished building target: Lesson_2.elf | ||
|
||
make --no-print-directory post-build | ||
Binary | ||
arm-none-eabi-objcopy -S -O binary "Lesson_2.elf" "Lesson_2.bin" | ||
|
||
Invoking: Cross ARM GNU Create Flash Image | ||
arm-none-eabi-objcopy -O ihex "Lesson_2.elf" "Lesson_2.hex" | ||
Finished building: Lesson_2.hex | ||
|
||
Invoking: Cross ARM GNU Print Size | ||
arm-none-eabi-size --format=berkeley "Lesson_2.elf" | ||
text data bss dec hex filename | ||
4537 208 420 5165 142d Lesson_2.elf | ||
Finished building: Lesson_2.siz | ||
|
||
Cannot run program "make": Unknown reason | ||
|
||
11:04:46 Build Finished (took 655ms) | ||
13:44:55 Build Finished (took 19ms) | ||
|
11 changes: 11 additions & 0 deletions
11
C_Course/USART/.metadata/.plugins/org.eclipse.cdt.ui/Lesson_2_P1.build.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
14:42:36 **** Incremental Build of configuration Debug for project Lesson_2_P1 **** | ||
make all | ||
Invoking: Cross ARM GNU Print Size | ||
arm-none-eabi-size --format=berkeley "Lesson_2_P1.elf" | ||
text data bss dec hex filename | ||
4645 208 420 5273 1499 Lesson_2_P1.elf | ||
Finished building: Lesson_2_P1.siz | ||
|
||
|
||
14:42:37 Build Finished (took 99ms) | ||
|
46 changes: 21 additions & 25 deletions
46
C_Course/USART/.metadata/.plugins/org.eclipse.cdt.ui/global-build.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,46 @@ | ||
11:04:33 **** Incremental Build of configuration Debug for project Lesson_2 **** | ||
make all | ||
Invoking: Cross ARM GNU Print Size | ||
arm-none-eabi-size --format=berkeley "Lesson_2.elf" | ||
text data bss dec hex filename | ||
4537 208 420 5165 142d Lesson_2.elf | ||
Finished building: Lesson_2.siz | ||
|
||
11:04:45 **** Incremental Build of configuration Debug for project Lesson_2 **** | ||
14:42:22 **** Incremental Build of configuration Debug for project Lesson_2_P1 **** | ||
make all | ||
Building file: ../src/MCU/usart2.c | ||
Invoking: Cross ARM C Compiler | ||
arm-none-eabi-gcc -mcpu=cortex-m0 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -Wall -Wextra -g3 -DDEBUG -DUSE_FULL_ASSERT -DTRACE -DOS_USE_TRACE_SEMIHOSTING_DEBUG -DSTM32F030 -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=8000000 -I"../include" -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f0-stdperiph" -std=gnu11 -MMD -MP -MF"src/MCU/usart2.d" -MT"src/MCU/usart2.o" -c -o "src/MCU/usart2.o" "../src/MCU/usart2.c" | ||
../src/MCU/usart2.c: In function 'Setbaudrate': | ||
../src/MCU/usart2.c:39:34: warning: unused parameter 'baud' [-Wunused-parameter] | ||
static void Setbaudrate(uint32_t baud) | ||
^ | ||
../src/MCU/usart2.c: In function 'SendByte': | ||
../src/MCU/usart2.c:107:38: warning: unused parameter 'source' [-Wunused-parameter] | ||
../src/MCU/usart2.c:137:38: warning: unused parameter 'source' [-Wunused-parameter] | ||
static uint_fast8_t SendByte(uint8_t source) | ||
^ | ||
../src/MCU/usart2.c: In function 'GetByte': | ||
../src/MCU/usart2.c:133:37: warning: unused parameter 'destination' [-Wunused-parameter] | ||
../src/MCU/usart2.c:163:37: warning: unused parameter 'destination' [-Wunused-parameter] | ||
static int_fast8_t GetByte(uint8_t *destination) | ||
^ | ||
../src/MCU/usart2.c: At top level: | ||
../src/MCU/usart2.c:51:21: warning: 'IsWriteBusy' defined but not used [-Wunused-function] | ||
../src/MCU/usart2.c:86:21: warning: 'IsWriteBusy' defined but not used [-Wunused-function] | ||
static uint_fast8_t IsWriteBusy(void) | ||
^ | ||
Finished building: ../src/MCU/usart2.c | ||
|
||
Building target: Lesson_2.elf | ||
Building target: Lesson_2_P1.elf | ||
Invoking: Cross ARM C++ Linker | ||
arm-none-eabi-g++ -mcpu=cortex-m0 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -Wall -Wextra -g3 -T mem.ld -T libs.ld -T sections.ld -nostartfiles -Xlinker --gc-sections -L"../ldscripts" -Wl,-Map,"Lesson_2.map" --specs=nano.specs -o "Lesson_2.elf" ./system/src/stm32f0-stdperiph/stm32f0xx_gpio.o ./system/src/stm32f0-stdperiph/stm32f0xx_rcc.o ./system/src/newlib/_cxx.o ./system/src/newlib/_exit.o ./system/src/newlib/_sbrk.o ./system/src/newlib/_startup.o ./system/src/newlib/_syscalls.o ./system/src/newlib/assert.o ./system/src/diag/Trace.o ./system/src/diag/trace_impl.o ./system/src/cortexm/_initialize_hardware.o ./system/src/cortexm/_reset_hardware.o ./system/src/cortexm/exception_handlers.o ./system/src/cmsis/system_stm32f0xx.o ./system/src/cmsis/vectors_stm32f0xx.o ./src/MCU/led.o ./src/MCU/tick.o ./src/MCU/usart2.o ./src/main.o | ||
Finished building target: Lesson_2.elf | ||
arm-none-eabi-g++ -mcpu=cortex-m0 -mthumb -Og -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -ffreestanding -fno-move-loop-invariants -Wall -Wextra -g3 -T mem.ld -T libs.ld -T sections.ld -nostartfiles -Xlinker --gc-sections -L"../ldscripts" -Wl,-Map,"Lesson_2_P1.map" --specs=nano.specs -o "Lesson_2_P1.elf" ./system/src/stm32f0-stdperiph/stm32f0xx_gpio.o ./system/src/stm32f0-stdperiph/stm32f0xx_rcc.o ./system/src/newlib/_cxx.o ./system/src/newlib/_exit.o ./system/src/newlib/_sbrk.o ./system/src/newlib/_startup.o ./system/src/newlib/_syscalls.o ./system/src/newlib/assert.o ./system/src/diag/Trace.o ./system/src/diag/trace_impl.o ./system/src/cortexm/_initialize_hardware.o ./system/src/cortexm/_reset_hardware.o ./system/src/cortexm/exception_handlers.o ./system/src/cmsis/system_stm32f0xx.o ./system/src/cmsis/vectors_stm32f0xx.o ./src/MCU/led.o ./src/MCU/tick.o ./src/MCU/usart2.o ./src/main.o | ||
Finished building target: Lesson_2_P1.elf | ||
|
||
make --no-print-directory post-build | ||
Binary | ||
arm-none-eabi-objcopy -S -O binary "Lesson_2.elf" "Lesson_2.bin" | ||
arm-none-eabi-objcopy -S -O binary "Lesson_2_P1.elf" "Lesson_2_P1.bin" | ||
|
||
Invoking: Cross ARM GNU Create Flash Image | ||
arm-none-eabi-objcopy -O ihex "Lesson_2.elf" "Lesson_2.hex" | ||
Finished building: Lesson_2.hex | ||
arm-none-eabi-objcopy -O ihex "Lesson_2_P1.elf" "Lesson_2_P1.hex" | ||
Finished building: Lesson_2_P1.hex | ||
|
||
Invoking: Cross ARM GNU Print Size | ||
arm-none-eabi-size --format=berkeley "Lesson_2.elf" | ||
arm-none-eabi-size --format=berkeley "Lesson_2_P1.elf" | ||
text data bss dec hex filename | ||
4645 208 420 5273 1499 Lesson_2_P1.elf | ||
Finished building: Lesson_2_P1.siz | ||
|
||
14:42:36 **** Incremental Build of configuration Debug for project Lesson_2_P1 **** | ||
make all | ||
Invoking: Cross ARM GNU Print Size | ||
arm-none-eabi-size --format=berkeley "Lesson_2_P1.elf" | ||
text data bss dec hex filename | ||
4537 208 420 5165 142d Lesson_2.elf | ||
Finished building: Lesson_2.siz | ||
4645 208 420 5273 1499 Lesson_2_P1.elf | ||
Finished building: Lesson_2_P1.siz | ||
|
1 change: 1 addition & 0 deletions
1
...story/c9/f011ddafdb5d00151e80a9a1d7f91d35 → ...story/10/103a57888b63001514fab6ca52fbd5a2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/Debug/ | ||
/Release/ | ||
/Debug/ |
231 changes: 231 additions & 0 deletions
231
...metadata/.plugins/org.eclipse.core.resources/.history/12/40c7a99d9363001512aab4ed8479ff16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,231 @@ | ||
///////////////////////////////////////////////////////////////////////// | ||
/// \file usart2.c | ||
/// \brief STM32 serial2 MCU hardware interface layer. to maintain | ||
/// code portability, the hardware related code is split from the main logic. | ||
/// | ||
/// Author: Ronald Sousa (Opticalworm) | ||
///////////////////////////////////////////////////////////////////////// | ||
#include "MCU/usart2.h" | ||
|
||
///////////////////////////////////////////////////////////////////////// | ||
/// \brief enable 16x oversampling. Used to reduce the baudrate calculation | ||
/// error. | ||
///////////////////////////////////////////////////////////////////////// | ||
//#efine USART_OVER_SAMPLE_16 | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
/// \brief Keeps track if the serial port is configure and opend | ||
/////////////////////////////////////////////////////////////////////////////// | ||
static uint_fast8_t IsOpenFlag = FALSE; | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
/// \brief return the serial open state | ||
/// | ||
/// \return true = the serial port is open else false | ||
/////////////////////////////////////////////////////////////////////////////// | ||
static uint_fast8_t IsSerialOpen(void) | ||
{ | ||
return IsOpenFlag; | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
/// \brief Open the serial port | ||
/// | ||
/// \return true = success else port is already open | ||
/////////////////////////////////////////////////////////////////////////////// | ||
static void Close(void) | ||
{ | ||
USART2->CR1 &= ~(1); | ||
} | ||
|
||
///////////////////////////////////////////////////////////////////////// | ||
/// \brief Set usart baudrate. can be called at any time. | ||
/// | ||
/// \param baud the desire baudrate | ||
/// | ||
/// \note setting baudrate will effect any data currently been sent.susb | ||
/// make sure that you check that the write buffer is empty | ||
///////////////////////////////////////////////////////////////////////// | ||
static void Setbaudrate(uint32_t baud) | ||
{ | ||
uint_fast8_t WasUartEnable = FALSE; | ||
|
||
uint16_t BaudrateTemp = 0; | ||
|
||
if (IsOpenFlag) | ||
{ | ||
WasUartEnable = TRUE; | ||
Close(); | ||
} | ||
|
||
#ifdef USART_OVER_SAMPLE_16 | ||
BaudrateTemp = (SystemCoreClock) / (baud); | ||
#else | ||
BaudrateTemp = (2 * SystemCoreClock) / (baud); | ||
|
||
BaudrateTemp = ((BaudrateTemp & 0xFFFFFFF0) | ((BaudrateTemp >> 1) & 0x00000007)); | ||
#endif | ||
|
||
USART2->BRR = BaudrateTemp; | ||
|
||
|
||
if(WasUartEnable) | ||
{ | ||
USART2->CR1 |= 1; | ||
} | ||
|
||
} | ||
|
||
///////////////////////////////////////////////////////////////////////// | ||
/// \brief you can use this function to check if the write buffer is | ||
/// empty and ready for new data | ||
/// | ||
/// \param destination pointer to return the read byte | ||
/// \return TRUE = Busy else ready. else false | ||
///////////////////////////////////////////////////////////////////////// | ||
static uint_fast8_t IsWriteBusy(void) | ||
{ | ||
/// \todo Need to implement Usart2 IsWriteBusy() | ||
return TRUE; | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
/// \brief Open the serial port. | ||
/// | ||
/// \param baudrate set the serial port baud rate | ||
/// | ||
/// \return true = success else port is already open | ||
/////////////////////////////////////////////////////////////////////////////// | ||
static uint_fast8_t Open(uint32_t baudrate) | ||
{ | ||
|
||
if(!IsOpenFlag) | ||
{ | ||
RCC->APB1ENR |= (1<<17); // en USART clock | ||
|
||
USART2->CR1 = 0; | ||
|
||
RCC->AHBENR |= (1<<17); // en GPIOA clock | ||
|
||
GPIOA->MODER &= ~(3<<4); // clear PA2 moder | ||
GPIOA->MODER |= (2<<4); // Set PA2 to alter function | ||
|
||
GPIOA->AFR[0] &= ~(0xF << 8); // clear PA2 config | ||
GPIOA->AFR[0] |= (1<<8); | ||
|
||
// set baudrate | ||
Setbaudrate(baudrate); | ||
|
||
|
||
USART2->CR1 |= (1<<15) | 1 | (1<<3); | ||
|
||
IsOpenFlag = TRUE; | ||
} | ||
return FALSE; | ||
} | ||
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
/// \brief Send a single byte | ||
/// | ||
/// \return true = success else port is not open | ||
/////////////////////////////////////////////////////////////////////////////// | ||
static uint_fast8_t SendByte(uint8_t source) | ||
{ | ||
/// \todo implement USART2 functions that send one byte | ||
return FALSE; | ||
} | ||
/////////////////////////////////////////////////////////////////////////////// | ||
/// \brief return the serial receive byte buffer state | ||
/// | ||
/// \return 1 = we have data | ||
/// 0 = no data to read | ||
/// -1 = Port is not open | ||
/////////////////////////////////////////////////////////////////////////////// | ||
static int_fast8_t DoesReceiveBufferHaveData(void) | ||
{ | ||
/// \todo implement USART2 functions that checks if we have data on the rx buffer. | ||
return -1; | ||
} | ||
/////////////////////////////////////////////////////////////////////////////// | ||
/// \brief serial port for reading serial byte | ||
/// | ||
/// \param destination pointer to return the newly read byte. | ||
/// | ||
/// \return 1 = success on reading a byte | ||
/// 0 = no data to read or | ||
/// -1 = Port is not open or the destination pointer is invalid | ||
/////////////////////////////////////////////////////////////////////////////// | ||
static int_fast8_t GetByte(uint8_t *destination) | ||
{ | ||
/// \todo implement USART2 functions that returns one byte. | ||
return -1; | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
/// \brief Write a string | ||
/// | ||
/// \param source pointer to the string to write. must end with null | ||
/// | ||
/// \return true = success else either the port is not open or the pointer | ||
/// to the array is invalid. | ||
/////////////////////////////////////////////////////////////////////////////// | ||
static uint_fast8_t SendString(const uint8_t *source) | ||
{ | ||
if (IsOpenFlag && source) | ||
{ | ||
while(*source) | ||
{ | ||
if (!SendByte(*source) ) | ||
{ | ||
return FALSE; | ||
} | ||
source++; | ||
} | ||
return TRUE; | ||
} | ||
return FALSE; | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
/// \brief Write an array of bytes | ||
/// | ||
/// \param source pointer to the array to transmit. | ||
/// \param length is the size of the array | ||
/// | ||
/// \return true = success else either the port is not open or the pointer | ||
/// to the array is invalid. | ||
/////////////////////////////////////////////////////////////////////////////// | ||
static uint_fast8_t SendArray(const uint8_t *source, uint32_t length) | ||
{ | ||
if (IsOpenFlag && source) | ||
{ | ||
for ( ; length ; length--) | ||
{ | ||
if ( !SendByte(*source) ) | ||
{ | ||
return FALSE; | ||
} | ||
source++; | ||
} | ||
return TRUE; | ||
} | ||
return FALSE; | ||
} | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
/// \brief Defines the standard serial functions for usart 2 | ||
/// | ||
/// /sa SerialInterface | ||
/////////////////////////////////////////////////////////////////////////////// | ||
SerialInterface SerialPort2 = { | ||
IsSerialOpen, | ||
Open, | ||
Close, | ||
SendByte, | ||
SendString, | ||
SendArray, | ||
DoesReceiveBufferHaveData, | ||
GetByte | ||
}; |
Oops, something went wrong.