Merge remote-tracking branch 'refs/remotes/origin/master' into Scheduler

This commit is contained in:
Jonas Holmberg 2016-09-26 14:58:57 +02:00
commit e23f6c5edd
2 changed files with 87 additions and 0 deletions

View File

@ -0,0 +1,40 @@
/*
* uart1_inverter.h
*
* Created on: 21 sep. 2016
* Author: Philip
*/
/**********************************************************************
* NAME: uart1_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_UART1_INVERTER_H_
#define DRIVERS_UART1_INVERTER_H_
#pragma once
/***********************************************************************
* BRIEF: Init Inverter *
* INFORMATION: Must be ran before inversion can be activated. *
* The "on" arg sets if the inverter should be initiated on or off *
***********************************************************************/
void uart1_rx_inverter_init(bool on);
/***********************************************************************
* BRIEF: Set Inverter *
* INFORMATION: Does not need bo be ran unless the value is changed. *
***********************************************************************/
void uart1_rx_inverter_set(bool on);
#endif /* DRIVERS_UART1_INVERTER_H_ */

View File

@ -0,0 +1,47 @@
/*
* uart1_inverter.c
*
* Created on: 21 sep. 2016
* Author: Philip
*/
/**********************************************************************
* NAME: uart1_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 uart1_rx_inverter_set(bool on);
/***********************************************************************
* BRIEF: Init Inverter *
* INFORMATION: Must be ran before inversion can be activated. *
* The "on" arg sets if the inverter should be initiated on or off *
***********************************************************************/
void uart1_rx_inverter_init(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);
uart1_rx_inverter_set(on);
}
/***********************************************************************
* BRIEF: Set Inverter *
* INFORMATION: Does not need bo be ran unless the value is changed. *
***********************************************************************/
void uart1_rx_inverter_set(bool on)
{
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_0,on ? GPIO_PIN_SET : GPIO_PIN_RESET);
}