Signed number for UART

This commit is contained in:
Yohan Boujon 2023-04-07 13:21:27 +02:00
parent 9606282533
commit a1d5cd57d8
7 changed files with 38 additions and 19 deletions

View file

@ -2,9 +2,9 @@
#include "gpio.h"
//faire GPIO
void (* pFncUART) (uint16_t data); /* d<>claration d<>un pointeur de fonction */
void (* pFncUART) (uint8_t data); /* d<>claration d<>un pointeur de fonction */
void MyUART_Init_Periph (void (* ptrFonction)(uint16_t))
void MyUART_Init_Periph (void (* ptrFonction)(uint8_t))
{
pFncUART = ptrFonction; /* affectation du pointeur */
}

View file

@ -32,5 +32,5 @@ void MyUART_Init(MyUART_Struct_Typedef * UARTStructPtr);
void MyUART_InitGPIO(MyUART_Struct_Typedef * UARTStructPtr);
void MyUART_Send(MyUART_Struct_Typedef *UART, uint8_t data);
uint8_t MyUART_Receive(MyUART_Struct_Typedef *UART);
void MyUART_Init_Periph (void (* ptrFonction)(uint16_t));
void MyUART_Init_Periph (void (* ptrFonction)(uint8_t));
#endif

View file

@ -1,16 +1,19 @@
#include "remote.h"
#include "../driver/gpio.h"
#include "gpio.h"
MyUART_Struct_Typedef uartCool = {USART1,9600,lengthBit8,parityNone,stopBit1};
void remote(uint16_t data)
void remote(uint8_t data)
{
MyUART_Send(&uartCool,data); //0x97 -> +100 (1001 0111?) 0x64 -> -100 (0110 0100)
//0xFE -> 2 , 0x02 ->-2
if(data > 50)
MyUART_Send(&uartCool,data);
int8_t signedData = (int8_t)data;
if(signedData > 0)
{
MyGPIO_Set(GPIOA,5);
}
else {
MyGPIO_Reset(GPIOA,5);
}
}
void initRemote(void)

View file

@ -1,10 +1,10 @@
#ifndef REMOTE_H
#define REMOTE_H
#include "../driver/uart.h"
#include "uart.h"
//XBEE 9600 baud, zero parite, 1 bit de stop,
void remote(uint16_t data);
void remote(uint8_t data);
void initRemote(void);
void testRemote(void);

View file

@ -1,8 +1,8 @@
#include "stm32f10x.h"
#include "../../driver/MyI2C.h"
#include "../../driver/MySPI.h"
#include "../../implementation/remote.h"
#include "../../driver/gpio.h"
#include "MyI2C.h"
#include "MySPI.h"
#include "remote.h"
#include "gpio.h"
int main (void)
{

View file

@ -388,18 +388,34 @@
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>15</LineNumber>
<LineNumber>10</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>134219676</Address>
<Address>134219708</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>.\Source\Principale.c</Filename>
<Filename>..\implementation\remote.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\cool_reel\Source/Principale.c\15</Expression>
<Expression>\\cool_reel\../implementation/remote.c\10</Expression>
</Bp>
<Bp>
<Number>1</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>..\implementation\remote.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<WatchWindow1>

View file

@ -767,7 +767,7 @@
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath>.\Include</IncludePath>
<IncludePath>.\Include;..\driver;..\implementation</IncludePath>
</VariousControls>
</Cads>
<Aads>