Ein Roboter mit bürstenlosem Antrieb, differenzial und NRF24L01 Funk. Großflächig gebaut um ein großes Solarpanel aufzunehmen.
https://gitlab.informatik.hs-fulda.de/fdai5253/roboter
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.0 KiB
45 lines
1.0 KiB
/*
|
|
* gpio_helper.c
|
|
*
|
|
* Created: 22/1/2016 15:28:48
|
|
* Author: akatran
|
|
*/
|
|
|
|
#include "gpio_helper.h"
|
|
|
|
/**
|
|
* Get the port corresponding in portnum. Default is PORTC.
|
|
*/
|
|
PORT_t * GPIO_getPort(int pinnum, uint8_t * pin_bm)
|
|
//PORT_t * GPIO_getPort(int portnum)
|
|
{
|
|
PORT_t * port = &PORTC;
|
|
if ( (pinnum >= XMEGA_PORTA_PIN0) && (pinnum<= XMEGA_PORTA_PIN7) )
|
|
{
|
|
port = &PORTA;
|
|
*pin_bm = (1<<pinnum);
|
|
}else if ( (pinnum >= XMEGA_PORTB_PIN0) && (pinnum<= XMEGA_PORTB_PIN7) )
|
|
{
|
|
port = &PORTB;
|
|
*pin_bm = (1<<(pinnum-8));
|
|
}else if ( (pinnum >= XMEGA_PORTC_PIN0) && (pinnum<= XMEGA_PORTC_PIN7) )
|
|
{
|
|
port = &PORTC;
|
|
*pin_bm = (1<<(pinnum-16));
|
|
}else if ( (pinnum >= XMEGA_PORTD_PIN0) && (pinnum<= XMEGA_PORTD_PIN7) )
|
|
{
|
|
port = &PORTD;
|
|
*pin_bm = (1<<(pinnum-24));
|
|
}else if ( (pinnum >= XMEGA_PORTE_PIN0) && (pinnum<= XMEGA_PORTE_PIN7) )
|
|
{
|
|
port = &PORTE;
|
|
*pin_bm = (1<<(pinnum-32));
|
|
}else if ( (pinnum >= XMEGA_PORTF_PIN0) && (pinnum<= XMEGA_PORTF_PIN7) )
|
|
{
|
|
port = &PORTF;
|
|
*pin_bm = (1<<(pinnum-40));
|
|
}
|
|
|
|
return port;
|
|
|
|
}
|