Modified uart driver, created base files
This commit is contained in:
parent
7009c70707
commit
b7d418f6ad
9 changed files with 173 additions and 21 deletions
|
@ -2,22 +2,15 @@
|
|||
#include "gpio.h"
|
||||
//faire GPIO
|
||||
|
||||
|
||||
char data1 = 0x00;
|
||||
char data2 = 0x00;
|
||||
char data3 = 0x00;
|
||||
|
||||
void MyUART_Init(MyUART_Struct_Typedef * UARTStructPtr){
|
||||
if (UARTStructPtr->UART == USART1)
|
||||
RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
|
||||
if (UARTStructPtr->UART == USART2)
|
||||
RCC->APB2ENR |= RCC_APB1ENR_USART2EN;
|
||||
if (UARTStructPtr->UART == USART3)
|
||||
RCC->APB2ENR |= RCC_APB1ENR_USART3EN;
|
||||
|
||||
UARTStructPtr->UART->BRR = 72000000/(UARTStructPtr->BaudRate);
|
||||
UARTStructPtr->UART->CR1 |= ((UARTStructPtr->Wlengh)<<12);
|
||||
UARTStructPtr->UART->CR1 |= (0x1<<10);
|
||||
MyUART_setClockBit(UARTStructPtr->UART);
|
||||
UARTStructPtr->UART->BRR = 72000000/(UARTStructPtr->BaudRate);
|
||||
UARTStructPtr->UART->CR1 |= ((UARTStructPtr->Wlengh)<<12);
|
||||
UARTStructPtr->UART->CR1 |= (0x1<<10);
|
||||
|
||||
if(UARTStructPtr->Wparity == parity_none)
|
||||
UARTStructPtr->UART->CR1 &= ~(0x1<<10);
|
||||
|
@ -37,6 +30,28 @@ void MyUART_Init(MyUART_Struct_Typedef * UARTStructPtr){
|
|||
NVIC_EnableIRQ(USART1_IRQn);
|
||||
}
|
||||
|
||||
int MyUART_setClockBit(USART_TypeDef * UART)
|
||||
{
|
||||
if (UART == USART1)
|
||||
{
|
||||
RCC->APB2ENR |= RCC_APB2ENR_USART1EN; //72MHz
|
||||
return 0;
|
||||
}
|
||||
else if (UART == USART2)
|
||||
{
|
||||
RCC->APB1ENR |= RCC_APB1ENR_USART2EN; //36MHz
|
||||
return 0;
|
||||
}
|
||||
else if (UART == USART3)
|
||||
{
|
||||
RCC->APB1ENR |= RCC_APB1ENR_USART3EN; //36MHz //Maybe return the clock base mhz ?
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
void USART1_IRQHandler(void)
|
||||
{
|
||||
// Check if receive data register not empty
|
||||
|
|
|
@ -8,9 +8,13 @@ typedef struct {
|
|||
unsigned char Wlengh;
|
||||
unsigned char Wparity;
|
||||
unsigned char Wstop;
|
||||
|
||||
}MyUART_Struct_Typedef;
|
||||
|
||||
typedef enum {
|
||||
//DIV_Fraction ->
|
||||
//1D4C
|
||||
}MyUART_BRR
|
||||
|
||||
#define parity_none 0x0
|
||||
#define parity_even 0x1
|
||||
#define parity_odd 0x2
|
||||
|
@ -20,8 +24,6 @@ typedef struct {
|
|||
#define stop2b 0x2
|
||||
|
||||
void MyUART_Init(MyUART_Struct_Typedef * UARTStructPtr);
|
||||
void USART1_IRQHandler(void);
|
||||
void USART2_IRQHandler(void);
|
||||
void USART3_IRQHandler(void);
|
||||
int MyUART_setClockBit(USART_TypeDef * UART);
|
||||
char MyUART_Read(MyUART_Struct_Typedef * UARTStructPtr);
|
||||
#endif
|
1
implementation/remote.c
Normal file
1
implementation/remote.c
Normal file
|
@ -0,0 +1 @@
|
|||
|
7
implementation/remote.h
Normal file
7
implementation/remote.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#ifndef REMOTE_H
|
||||
#define REMOTE_H
|
||||
#include "../driver/uart.h"
|
||||
|
||||
//XBEE 9600 baud, zero parite, 1 bit de stop,
|
||||
|
||||
#endif
|
|
@ -1,6 +1,7 @@
|
|||
#include "stm32f10x.h"
|
||||
#include "../../driver/MyI2C.h"
|
||||
#include "../../driver/MySPI.h"
|
||||
#include "../../implementation/remote.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
|
|
|
@ -203,6 +203,22 @@
|
|||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>4</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>9</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>.\Source\Principale.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
|
@ -510,6 +526,18 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>1</GroupNumber>
|
||||
<FileNumber>2</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\implementation\remote.c</PathWithFileName>
|
||||
<FilenameWithoutPath>remote.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
|
@ -520,7 +548,7 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>2</FileNumber>
|
||||
<FileNumber>3</FileNumber>
|
||||
<FileType>4</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
@ -530,6 +558,54 @@
|
|||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>4</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\driver\adc.c</PathWithFileName>
|
||||
<FilenameWithoutPath>adc.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>5</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\driver\gpio.c</PathWithFileName>
|
||||
<FilenameWithoutPath>gpio.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>6</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\driver\timer.c</PathWithFileName>
|
||||
<FilenameWithoutPath>timer.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\driver\uart.c</PathWithFileName>
|
||||
<FilenameWithoutPath>uart.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
|
|
|
@ -388,6 +388,11 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>.\Source\Principale.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>remote.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\implementation\remote.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -398,6 +403,26 @@
|
|||
<FileType>4</FileType>
|
||||
<FilePath>..\driver\Lib_Com_Periph_2022.lib</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\driver\adc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\driver\gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>timer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\driver\timer.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\driver\uart.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -790,6 +815,11 @@
|
|||
<FileType>1</FileType>
|
||||
<FilePath>.\Source\Principale.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>remote.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\implementation\remote.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -800,6 +830,26 @@
|
|||
<FileType>4</FileType>
|
||||
<FilePath>..\driver\Lib_Com_Periph_2022.lib</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>adc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\driver\adc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\driver\gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>timer.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\driver\timer.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\driver\uart.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
|
Loading…
Reference in a new issue