Inverter for UART1 implemented. Not tested

This commit is contained in:
philsson 2016-09-21 16:27:24 +02:00
parent b16127441d
commit 1de3babe98
2 changed files with 85 additions and 0 deletions

View 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_ */

View 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);
}