Files
HendiControlFirmware/Control/firmware/uart_echo/port.c
T
jens f6fca1e28b - fixed ports
- added power switch and command
- temporarly disabled command and ADC event

git-svn-id: http://moon:8086/svn/projects/HendiControl@23 fda53097-d464-4ada-af97-ba876c37ca34
2019-02-20 22:17:14 +00:00

56 lines
910 B
C

/*
* port.c
*
* Created: 20.02.2019 20:54:33
* Author: jens
*/
#include <avr/io.h>
#include "port.h"
void port_init()
{
DDRB = 0x03;
DDRC = 0x01;
PORTB = PORTB | 0x03;
PORTC = PORTC | 0x01;
}
typedef struct _sPort_t
{
uint8_t port;
uint8_t pin;
uint8_t pol;
} Port_t;
const Port_t portItems[NUM_ITEMS] =
{
{0x05, 0, 1},
{0x05, 1, 1},
{0x05, 2, 1},
{0x08, 0, 1},
};
void portSet(int portItem, int enable)
{
uint8_t addr = portItems[portItem].port;
uint8_t pin_mask = 1 << portItems[portItem].pin;
if (enable ^ portItems[portItem].pol)
{
_SFR_IO8(addr) |= pin_mask;
}
else
{
_SFR_IO8(addr) &= ~pin_mask;
}
}
int portGet(int portItem)
{
uint8_t addr = portItems[portItem].port;
uint8_t pin_mask = 1 << portItems[portItem].pin;
int enable = (_SFR_IO8(addr) & pin_mask) != portItems[portItem].pol;
return enable;
}