UART1 SP inversion fix (BlueJayF4)
This commit is contained in:
parent
e2ad32cd5e
commit
9bf469ac32
|
@ -46,6 +46,14 @@ void detectHardwareRevision(void)
|
|||
*/
|
||||
if (!IORead(pin1)) {
|
||||
hardwareRevision = BJF4_REV3;
|
||||
|
||||
IO_t pin2 = IOGetByTag(IO_TAG(PB13));
|
||||
IOInit(pin2, OWNER_SYSTEM, 2);
|
||||
IOConfigGPIO(pin2, IOCFG_IPU);
|
||||
|
||||
if (!IORead(pin2)) {
|
||||
hardwareRevision = BJF4_REV4;
|
||||
}
|
||||
} else {
|
||||
IO_t pin2 = IOGetByTag(IO_TAG(PB13));
|
||||
IOInit(pin2, OWNER_SYSTEM, 2);
|
||||
|
@ -62,18 +70,6 @@ void detectHardwareRevision(void)
|
|||
hardwareRevision = BJF4_REV2;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
enable the UART1 inversion PC9
|
||||
|
||||
TODO: once param groups are in place, inverter outputs
|
||||
can be moved to be simple IO outputs, and merely set them
|
||||
HI or LO in configuration.
|
||||
*/
|
||||
IO_t uart1invert = IOGetByTag(IO_TAG(PC9));
|
||||
IOInit(uart1invert, OWNER_INVERTER, 2);
|
||||
IOConfigGPIO(uart1invert, IOCFG_AF_PP);
|
||||
IOLo(uart1invert);
|
||||
}
|
||||
|
||||
void updateHardwareRevision(void)
|
||||
|
|
|
@ -18,10 +18,11 @@
|
|||
|
||||
typedef enum bjf4HardwareRevision_t {
|
||||
UNKNOWN = 0,
|
||||
BJF4_REV1, // Flash
|
||||
BJF4_REV2, // SDCard
|
||||
BJF4_REV3, // SDCard + Flash
|
||||
BJF4_REV1, // Flash
|
||||
BJF4_REV2, // SDCard
|
||||
BJF4_REV3, // SDCard + Flash
|
||||
BJF4_MINI_REV3A, // Flash (20x20 mini format)
|
||||
BJF4_REV4 // SDCard only - improved UART1 inversion
|
||||
} bjf4HardwareRevision_e;
|
||||
|
||||
extern uint8_t hardwareRevision;
|
||||
|
|
|
@ -28,16 +28,33 @@
|
|||
|
||||
void targetPreInit(void)
|
||||
{
|
||||
/* enable the built in inverter if telemetry is setup for the UART1 */
|
||||
if (serialConfig()->portConfigs[SERIAL_PORT_USART1].functionMask & FUNCTION_TELEMETRY_SMARTPORT &&
|
||||
telemetryConfig()->telemetry_inversion &&
|
||||
feature(FEATURE_TELEMETRY)) {
|
||||
IO_t io = IOGetByTag(IO_TAG(UART1_INVERTER));
|
||||
IOInit(io, OWNER_INVERTER, 1);
|
||||
IOConfigGPIO(io, IOCFG_OUT_PP);
|
||||
IOHi(io);
|
||||
switch (hardwareRevision) {
|
||||
case BJF4_REV3:
|
||||
case BJF4_MINI_REV3A:
|
||||
case BJF4_REV4:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
IO_t inverter = IOGetByTag(IO_TAG(UART1_INVERTER));
|
||||
IOInit(inverter, OWNER_INVERTER, 1);
|
||||
IOConfigGPIO(inverter, IOCFG_OUT_PP);
|
||||
|
||||
bool high = false;
|
||||
serialPortConfig_t *portConfig = serialFindPortConfiguration(SERIAL_PORT_USART1);
|
||||
if (portConfig) {
|
||||
bool smartportEnabled = (portConfig->functionMask & FUNCTION_TELEMETRY_SMARTPORT);
|
||||
if (smartportEnabled && (telemetryConfig()->telemetry_inversion) && (feature(FEATURE_TELEMETRY))) {
|
||||
high = true;
|
||||
}
|
||||
}
|
||||
/* reverse this for rev4, as it does not use the XOR gate */
|
||||
if (hardwareRevision == BJF4_REV4) {
|
||||
high = !high;
|
||||
}
|
||||
IOWrite(inverter, high);
|
||||
|
||||
/* ensure the CS pin for the flash is pulled hi so any SD card initialisation does not impact the chip */
|
||||
if (hardwareRevision == BJF4_REV3) {
|
||||
IO_t io = IOGetByTag(IO_TAG(M25P16_CS_PIN));
|
||||
|
|
Loading…
Reference in New Issue