示例#1
0
void initSlowChannel(int logicChannel, int hwChannel) {
	internalAdcIndexByHardwareIndex[hwChannel] = logicChannel;
	hardwareIndexByIndernalAdcIndex[logicChannel] = hwChannel;
	if (logicChannel < 6) {
		adcgrpcfg_slow.sqr3 += (hwChannel) << (5 * logicChannel);
	} else {
		adcgrpcfg_slow.sqr2 += (hwChannel) << (5 * (logicChannel - 6));
	}

	initAdcHwChannel(hwChannel);
}
示例#2
0
void AdcDevice::addChannel(adc_channel_e hwChannel) {
	int logicChannel = channelCount++;

	internalAdcIndexByHardwareIndex[hwChannel] = logicChannel;
	hardwareIndexByIndernalAdcIndex[logicChannel] = hwChannel;
	if (logicChannel < 6) {
		hwConfig->sqr3 += (hwChannel) << (5 * logicChannel);
	} else if (logicChannel < 12) {
		hwConfig->sqr2 += (hwChannel) << (5 * (logicChannel - 6));
	} else {
		hwConfig->sqr1 += (hwChannel) << (5 * (logicChannel - 12));
	}
	// todo: support for more then 12 channels? not sure how needed it would be

	initAdcHwChannel(hwChannel);
}
示例#3
0
void AdcDevice::enableChannelAndPin(adc_channel_e hwChannel) {
	enableChannel(hwChannel);

	initAdcHwChannel(hwChannel);
}