相关PIO接口
#define PIOS_PER_BANK 32U
#define PioCommonPioBank(_pio) ((_pio) / PIOS_PER_BANK)
#define PioCommonPioMask(_pio) (1UL << ((_pio) % PIOS_PER_BANK))
uint32 PioSetDir32Bank(uint16 bank, uint32 mask, uint32 dir);
uint32 PioSet32Bank(uint16 bank, uint32 mask, uint32 bits);
uint32 PioGet32Bank(uint16 bank);
如thermistor初始化为例:
const thermistorConfig thermistor_config = {
.on = THERMISTOR_ON,
.adc = THERMISTOR_ADC,
};
/*! The thermistor configuration */
extern const thermistorConfig thermistor_config;
/*! Returns the thermistor configration */
#define appConfigThermistor() (&thermistor_config)
void appTemperatureSensorInit(void)
{
uint8 on = appConfigThermistor()->on;
if (on != THERMISTOR_PIO_UNUSED)
{
/* Setup 'on' PIO as output (driving low) */
uint16 bank = PioCommonPioBank(on);
uint32 mask = PioCommonPioMask(on);
PanicNotZero(PioSetMapPins32Bank(bank, mask, mask));
PanicNotZero(PioSetDir32Bank(bank, mask, mask));
PanicNotZero(PioSet32Bank(bank, mask, 0));
}
}