- 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
This commit is contained in:
@@ -10,7 +10,47 @@
|
||||
|
||||
void port_init()
|
||||
{
|
||||
DDRB = 0x03;
|
||||
DDRC = 0x01;
|
||||
PORTB = PORTB | 0x03;
|
||||
DDRB = DDB1 | DDB2;
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user