Array of Port/Pal objects

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Array of Port/Pal objects

Post by Tabulous »

if i wanted to create an array of port pins what data types would i need to use i.e

what would x and y need to be, i'm abit unsure looking at the pal driver.

Code: Select all


typedef struct {
    x port;
   y pin;
}PINTBL_TypeDef;


static const PINTBL_TypeDef table[] =
{
   {   GPIOA,      GPIOA_PIN4,         },
   {   GPIOB,      GPIOB_PIN5,         },
};


usage :-

Code: Select all

PINTBL_TypeDef *p;


p = &table[i];
palReadPad(p->port, p->pin)
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Array of Port/Pal objects

Post by Giovanni »

Hi,

Use ioline_t, it represent both a port and a pin, no need to make that structure.

Giovanni
Post Reply