Inverter for UART1 implemented. Not tested
This commit is contained in:
parent
b16127441d
commit
1de3babe98
39
UAV-ControlSystem/inc/drivers/inverter.h
Normal file
39
UAV-ControlSystem/inc/drivers/inverter.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* inverter.h
|
||||||
|
*
|
||||||
|
* Created on: 21 sep. 2016
|
||||||
|
* Author: Philip
|
||||||
|
*/
|
||||||
|
/**********************************************************************
|
||||||
|
* NAME: inverter.h *
|
||||||
|
* AUTHOR: Philip Johansson *
|
||||||
|
* PURPOSE: Flip USART inversion on USART0 *
|
||||||
|
* INFORMATION: *
|
||||||
|
* This functionality exists only on USART0. *
|
||||||
|
* Initialize with the desired value *
|
||||||
|
* *
|
||||||
|
* GLOBAL VARIABLES: *
|
||||||
|
* Variable Type Description *
|
||||||
|
* -------- ---- ----------- *
|
||||||
|
* *
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef DRIVERS_INVERTER_H_
|
||||||
|
#define DRIVERS_INVERTER_H_
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* BRIEF: Init Inverter *
|
||||||
|
* INFORMATION: Must be ran before inversion can be activated. *
|
||||||
|
***********************************************************************/
|
||||||
|
void initInverter(bool on);
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* BRIEF: Set Inverter *
|
||||||
|
* INFORMATION: Does not need bo be ran unless the value is changed. *
|
||||||
|
***********************************************************************/
|
||||||
|
void inverterSet(bool on);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* DRIVERS_INVERTER_H_ */
|
46
UAV-ControlSystem/src/drivers/inverter.c
Normal file
46
UAV-ControlSystem/src/drivers/inverter.c
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* inverter.c
|
||||||
|
*
|
||||||
|
* Created on: 21 sep. 2016
|
||||||
|
* Author: Philip
|
||||||
|
*/
|
||||||
|
/**********************************************************************
|
||||||
|
* NAME: inverter.h *
|
||||||
|
* AUTHOR: Philip Johansson *
|
||||||
|
* PURPOSE: Flip USART inversion on USART0 *
|
||||||
|
* INFORMATION: *
|
||||||
|
* This functionality exists only on USART0. *
|
||||||
|
* Initialize with the desired value *
|
||||||
|
* *
|
||||||
|
* GLOBAL VARIABLES: *
|
||||||
|
* Variable Type Description *
|
||||||
|
* -------- ---- ----------- *
|
||||||
|
* *
|
||||||
|
**********************************************************************/
|
||||||
|
#include "stm32f4xx.h"
|
||||||
|
|
||||||
|
void inverterSet(bool on);
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* BRIEF: Init Inverter *
|
||||||
|
* INFORMATION: Must be ran before inversion can be activated. *
|
||||||
|
***********************************************************************/
|
||||||
|
void initInverter(bool on)
|
||||||
|
{
|
||||||
|
GPIO_InitTypeDef gpinit;
|
||||||
|
gpinit.Pin = GPIO_PIN_0;
|
||||||
|
gpinit.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
gpinit.Pull = GPIO_NOPULL;// OBS different from other IOs as they have PULLUP
|
||||||
|
gpinit.Speed = GPIO_SPEED_HIGH;
|
||||||
|
HAL_GPIO_Init(GPIOC, &gpinit);
|
||||||
|
inverterset(on);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* BRIEF: Set Inverter *
|
||||||
|
* INFORMATION: Does not need bo be ran unless the value is changed. *
|
||||||
|
***********************************************************************/
|
||||||
|
void inverterSet(bool on)
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_0,on ? GPIO_PIN_SET : GPIO_PIN_RESET);
|
||||||
|
}
|
Reference in New Issue
Block a user