mirror of
https://git.etud.insa-toulouse.fr/boujon/voilier-team-1.git
synced 2025-06-08 16:00:49 +02:00
Added MyUART_InitGPIO() function to init directly the GPIO for UART
This commit is contained in:
parent
b2f1785052
commit
820a3db260
5 changed files with 84 additions and 26 deletions
|
@ -61,6 +61,29 @@ void MyUART_ActiveIT(USART_TypeDef * UART, uint8_t Prio)
|
||||||
NVIC->ISER[1] |= (0x1<<(IRQNumber-32)); //Active l'interruption au niveau NVIC (p.119 manuel programming pour ISER[0])
|
NVIC->ISER[1] |= (0x1<<(IRQNumber-32)); //Active l'interruption au niveau NVIC (p.119 manuel programming pour ISER[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyUART_InitGPIO(MyUART_Struct_Typedef * UARTStructPtr)
|
||||||
|
{
|
||||||
|
MyGPIO_Struct_TypeDef rxd,txd;
|
||||||
|
if(UARTStructPtr->UART == USART1)
|
||||||
|
{
|
||||||
|
rxd = (MyGPIO_Struct_TypeDef){GPIOA,10,In_PullUp};
|
||||||
|
txd = (MyGPIO_Struct_TypeDef){GPIOA,9,AltOut_Ppull};
|
||||||
|
}
|
||||||
|
else if(UARTStructPtr->UART == USART2) {
|
||||||
|
rxd = (MyGPIO_Struct_TypeDef){GPIOA,3,In_Floating};
|
||||||
|
txd = (MyGPIO_Struct_TypeDef){GPIOA,2,AltOut_Ppull};
|
||||||
|
}
|
||||||
|
else if(UARTStructPtr->UART == USART3) {
|
||||||
|
rxd = (MyGPIO_Struct_TypeDef){GPIOB,11,In_PullUp};
|
||||||
|
txd = (MyGPIO_Struct_TypeDef){GPIOB,10,AltOut_Ppull};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MyGPIO_Init(&rxd);
|
||||||
|
MyGPIO_Init(&txd);
|
||||||
|
}
|
||||||
|
|
||||||
void MyUART_Send(MyUART_Struct_Typedef *UART, uint8_t data)
|
void MyUART_Send(MyUART_Struct_Typedef *UART, uint8_t data)
|
||||||
{
|
{
|
||||||
UART->UART->DR = data;
|
UART->UART->DR = data;
|
||||||
|
|
|
@ -29,6 +29,7 @@ typedef struct {
|
||||||
}MyUART_Struct_Typedef;
|
}MyUART_Struct_Typedef;
|
||||||
|
|
||||||
void MyUART_Init(MyUART_Struct_Typedef * UARTStructPtr);
|
void MyUART_Init(MyUART_Struct_Typedef * UARTStructPtr);
|
||||||
|
void MyUART_InitGPIO(MyUART_Struct_Typedef * UARTStructPtr);
|
||||||
int MyUART_setClockBit(MyUART_Struct_Typedef * UARTStructPtr);
|
int MyUART_setClockBit(MyUART_Struct_Typedef * UARTStructPtr);
|
||||||
void MyUART_Send(MyUART_Struct_Typedef *UART, uint8_t data);
|
void MyUART_Send(MyUART_Struct_Typedef *UART, uint8_t data);
|
||||||
uint8_t MyUART_Receive(MyUART_Struct_Typedef *UART);
|
uint8_t MyUART_Receive(MyUART_Struct_Typedef *UART);
|
||||||
|
|
|
@ -6,32 +6,20 @@
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
//rxd input pull up, txd output none
|
//MyGPIO_Struct_TypeDef led = {GPIOA,5,Out_PullUp}; //led
|
||||||
MyGPIO_Struct_TypeDef led = {GPIOA,5,Out_PullUp}; //led
|
//MyGPIO_Init(&led); //test des leds pour ignorer les contraintes liées aux différents ports
|
||||||
MyGPIO_Struct_TypeDef rxd1 = {GPIOA,10,In_PullUp};
|
|
||||||
MyGPIO_Struct_TypeDef txd1 = {GPIOA,9,AltOut_Ppull};
|
|
||||||
MyGPIO_Struct_TypeDef rxd2 = {GPIOA,3,In_Floating};
|
|
||||||
MyGPIO_Struct_TypeDef txd2 = {GPIOA,2,AltOut_Ppull};
|
|
||||||
MyGPIO_Struct_TypeDef rxd3 = {GPIOB,11,In_PullUp};
|
|
||||||
MyGPIO_Struct_TypeDef txd3 = {GPIOB,10,AltOut_Ppull};
|
|
||||||
MyUART_Struct_Typedef uartCool = {USART3,9600,lengthBit8,parityNone,stopBit1};
|
|
||||||
|
|
||||||
MyGPIO_Init(&led);
|
MyUART_Struct_Typedef uartCool = {USART2,9600,lengthBit8,parityNone,stopBit1};
|
||||||
MyGPIO_Init(&rxd1);
|
|
||||||
MyGPIO_Init(&txd1);
|
MyUART_InitGPIO(&uartCool);
|
||||||
MyGPIO_Init(&rxd2);
|
|
||||||
MyGPIO_Init(&txd2);
|
|
||||||
MyGPIO_Init(&rxd3);
|
|
||||||
MyGPIO_Init(&txd3);
|
|
||||||
MyUART_Init(&uartCool);
|
MyUART_Init(&uartCool);
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
if(MyUART_Read(&uartCool) == 0x61)
|
if(MyUART_Read(&uartCool) == 0x61)
|
||||||
{
|
{
|
||||||
MyGPIO_Set(GPIOA,5);
|
MyGPIO_Set(GPIOA,5);
|
||||||
MyUART_Send(&uartCool,'k');
|
|
||||||
MyUART_Send(&uartCool,'o');
|
MyUART_Send(&uartCool,'o');
|
||||||
MyUART_Send(&uartCool,'\n');
|
MyUART_Send(&uartCool,'k');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -433,6 +433,54 @@
|
||||||
<ExecCommand></ExecCommand>
|
<ExecCommand></ExecCommand>
|
||||||
<Expression></Expression>
|
<Expression></Expression>
|
||||||
</Bp>
|
</Bp>
|
||||||
|
<Bp>
|
||||||
|
<Number>3</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>17</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>
|
||||||
|
<Bp>
|
||||||
|
<Number>4</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>19</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>
|
||||||
|
<Bp>
|
||||||
|
<Number>5</Number>
|
||||||
|
<Type>0</Type>
|
||||||
|
<LineNumber>20</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>
|
</Breakpoint>
|
||||||
<WatchWindow1>
|
<WatchWindow1>
|
||||||
<Ww>
|
<Ww>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<TargetCommonOption>
|
<TargetCommonOption>
|
||||||
<Device>STM32F103RB</Device>
|
<Device>STM32F103RB</Device>
|
||||||
<Vendor>STMicroelectronics</Vendor>
|
<Vendor>STMicroelectronics</Vendor>
|
||||||
<PackID>Keil.STM32F1xx_DFP.2.4.0</PackID>
|
<PackID>Keil.STM32F1xx_DFP.2.3.0</PackID>
|
||||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||||
<Cpu>IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00020000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
|
<Cpu>IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00020000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
|
||||||
<FlashUtilSpec></FlashUtilSpec>
|
<FlashUtilSpec></FlashUtilSpec>
|
||||||
|
@ -187,7 +187,6 @@
|
||||||
<RvdsVP>0</RvdsVP>
|
<RvdsVP>0</RvdsVP>
|
||||||
<RvdsMve>0</RvdsMve>
|
<RvdsMve>0</RvdsMve>
|
||||||
<RvdsCdeCp>0</RvdsCdeCp>
|
<RvdsCdeCp>0</RvdsCdeCp>
|
||||||
<nBranchProt>0</nBranchProt>
|
|
||||||
<hadIRAM2>0</hadIRAM2>
|
<hadIRAM2>0</hadIRAM2>
|
||||||
<hadIROM2>0</hadIROM2>
|
<hadIROM2>0</hadIROM2>
|
||||||
<StupSel>8</StupSel>
|
<StupSel>8</StupSel>
|
||||||
|
@ -439,13 +438,13 @@
|
||||||
<TargetName>Réel</TargetName>
|
<TargetName>Réel</TargetName>
|
||||||
<ToolsetNumber>0x4</ToolsetNumber>
|
<ToolsetNumber>0x4</ToolsetNumber>
|
||||||
<ToolsetName>ARM-ADS</ToolsetName>
|
<ToolsetName>ARM-ADS</ToolsetName>
|
||||||
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7</pCCUsed>
|
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
|
||||||
<uAC6>0</uAC6>
|
<uAC6>0</uAC6>
|
||||||
<TargetOption>
|
<TargetOption>
|
||||||
<TargetCommonOption>
|
<TargetCommonOption>
|
||||||
<Device>STM32F103RB</Device>
|
<Device>STM32F103RB</Device>
|
||||||
<Vendor>STMicroelectronics</Vendor>
|
<Vendor>STMicroelectronics</Vendor>
|
||||||
<PackID>Keil.STM32F1xx_DFP.2.4.0</PackID>
|
<PackID>Keil.STM32F1xx_DFP.2.3.0</PackID>
|
||||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||||
<Cpu>IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00020000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
|
<Cpu>IRAM(0x20000000,0x00005000) IROM(0x08000000,0x00020000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
|
||||||
<FlashUtilSpec></FlashUtilSpec>
|
<FlashUtilSpec></FlashUtilSpec>
|
||||||
|
@ -615,7 +614,6 @@
|
||||||
<RvdsVP>0</RvdsVP>
|
<RvdsVP>0</RvdsVP>
|
||||||
<RvdsMve>0</RvdsMve>
|
<RvdsMve>0</RvdsMve>
|
||||||
<RvdsCdeCp>0</RvdsCdeCp>
|
<RvdsCdeCp>0</RvdsCdeCp>
|
||||||
<nBranchProt>0</nBranchProt>
|
|
||||||
<hadIRAM2>0</hadIRAM2>
|
<hadIRAM2>0</hadIRAM2>
|
||||||
<hadIROM2>0</hadIROM2>
|
<hadIROM2>0</hadIROM2>
|
||||||
<StupSel>8</StupSel>
|
<StupSel>8</StupSel>
|
||||||
|
@ -887,7 +885,7 @@
|
||||||
<file attr="config" category="header" name="RTE_Driver\Config\RTE_Device.h" version="1.1.2">
|
<file attr="config" category="header" name="RTE_Driver\Config\RTE_Device.h" version="1.1.2">
|
||||||
<instance index="0">RTE\Device\STM32F103RB\RTE_Device.h</instance>
|
<instance index="0">RTE\Device\STM32F103RB\RTE_Device.h</instance>
|
||||||
<component Cclass="Device" Cgroup="Startup" Cvendor="Keil" Cversion="1.0.0" condition="STM32F1xx CMSIS"/>
|
<component Cclass="Device" Cgroup="Startup" Cvendor="Keil" Cversion="1.0.0" condition="STM32F1xx CMSIS"/>
|
||||||
<package name="STM32F1xx_DFP" schemaVersion="1.7.2" url="http://www.keil.com/pack/" vendor="Keil" version="2.4.0"/>
|
<package name="STM32F1xx_DFP" schemaVersion="1.4.0" url="http://www.keil.com/pack/" vendor="Keil" version="2.3.0"/>
|
||||||
<targetInfos>
|
<targetInfos>
|
||||||
<targetInfo name="Réel"/>
|
<targetInfo name="Réel"/>
|
||||||
<targetInfo name="Simulé"/>
|
<targetInfo name="Simulé"/>
|
||||||
|
@ -896,7 +894,7 @@
|
||||||
<file attr="config" category="source" condition="STM32F1xx MD ARMCC" name="Device\Source\ARM\startup_stm32f10x_md.s" version="1.0.1">
|
<file attr="config" category="source" condition="STM32F1xx MD ARMCC" name="Device\Source\ARM\startup_stm32f10x_md.s" version="1.0.1">
|
||||||
<instance index="0">RTE\Device\STM32F103RB\startup_stm32f10x_md.s</instance>
|
<instance index="0">RTE\Device\STM32F103RB\startup_stm32f10x_md.s</instance>
|
||||||
<component Cclass="Device" Cgroup="Startup" Cvendor="Keil" Cversion="1.0.0" condition="STM32F1xx CMSIS"/>
|
<component Cclass="Device" Cgroup="Startup" Cvendor="Keil" Cversion="1.0.0" condition="STM32F1xx CMSIS"/>
|
||||||
<package name="STM32F1xx_DFP" schemaVersion="1.7.2" url="http://www.keil.com/pack/" vendor="Keil" version="2.4.0"/>
|
<package name="STM32F1xx_DFP" schemaVersion="1.4.0" url="http://www.keil.com/pack/" vendor="Keil" version="2.3.0"/>
|
||||||
<targetInfos>
|
<targetInfos>
|
||||||
<targetInfo name="Réel"/>
|
<targetInfo name="Réel"/>
|
||||||
<targetInfo name="Simulé"/>
|
<targetInfo name="Simulé"/>
|
||||||
|
@ -905,7 +903,7 @@
|
||||||
<file attr="config" category="source" name="Device\Source\system_stm32f10x.c" version="1.0.1">
|
<file attr="config" category="source" name="Device\Source\system_stm32f10x.c" version="1.0.1">
|
||||||
<instance index="0">RTE\Device\STM32F103RB\system_stm32f10x.c</instance>
|
<instance index="0">RTE\Device\STM32F103RB\system_stm32f10x.c</instance>
|
||||||
<component Cclass="Device" Cgroup="Startup" Cvendor="Keil" Cversion="1.0.0" condition="STM32F1xx CMSIS"/>
|
<component Cclass="Device" Cgroup="Startup" Cvendor="Keil" Cversion="1.0.0" condition="STM32F1xx CMSIS"/>
|
||||||
<package name="STM32F1xx_DFP" schemaVersion="1.7.2" url="http://www.keil.com/pack/" vendor="Keil" version="2.4.0"/>
|
<package name="STM32F1xx_DFP" schemaVersion="1.4.0" url="http://www.keil.com/pack/" vendor="Keil" version="2.3.0"/>
|
||||||
<targetInfos>
|
<targetInfos>
|
||||||
<targetInfo name="Réel"/>
|
<targetInfo name="Réel"/>
|
||||||
<targetInfo name="Simulé"/>
|
<targetInfo name="Simulé"/>
|
||||||
|
|
Loading…
Add table
Reference in a new issue