mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
./workspace/TS100 -> ./source/
This commit is contained in:
66
source/Core/BSP/Pine64/QC_GPIO.cpp
Normal file
66
source/Core/BSP/Pine64/QC_GPIO.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* QC.c
|
||||
*
|
||||
* Created on: 29 May 2020
|
||||
* Author: Ralim
|
||||
*/
|
||||
#include "gd32vf103_libopt.h"
|
||||
#include "BSP.h"
|
||||
#include "Pins.h"
|
||||
#include "QC3.h"
|
||||
#include "Settings.h"
|
||||
|
||||
#ifdef POW_QC
|
||||
void QC_DPlusZero_Six() {
|
||||
// pull down D+
|
||||
gpio_bit_reset(QC_DP_LOW_GPIO_Port, QC_DP_LOW_Pin);
|
||||
}
|
||||
void QC_DNegZero_Six() {
|
||||
gpio_bit_set(QC_DM_HIGH_GPIO_Port, QC_DM_HIGH_Pin);
|
||||
gpio_bit_reset(QC_DM_LOW_GPIO_Port, QC_DM_LOW_Pin);
|
||||
|
||||
}
|
||||
void QC_DPlusThree_Three() {
|
||||
// pull up D+
|
||||
gpio_bit_set(QC_DP_LOW_GPIO_Port, QC_DP_LOW_Pin);
|
||||
}
|
||||
void QC_DNegThree_Three() {
|
||||
gpio_bit_set(QC_DM_LOW_GPIO_Port, QC_DM_LOW_Pin);
|
||||
gpio_bit_set(QC_DM_HIGH_GPIO_Port, QC_DM_HIGH_Pin);
|
||||
}
|
||||
void QC_DM_PullDown() {
|
||||
gpio_init(USB_DM_LOW_GPIO_Port, GPIO_MODE_IPD, GPIO_OSPEED_2MHZ, USB_DM_Pin);
|
||||
}
|
||||
void QC_DM_No_PullDown() {
|
||||
gpio_init(USB_DM_LOW_GPIO_Port, GPIO_MODE_IN_FLOATING, GPIO_OSPEED_2MHZ, USB_DM_Pin);
|
||||
}
|
||||
void QC_Init_GPIO() {
|
||||
// Setup any GPIO into the right states for QC
|
||||
//D+ pulldown as output
|
||||
gpio_init(QC_DP_LOW_GPIO_Port, GPIO_MODE_OUT_PP, GPIO_OSPEED_2MHZ, QC_DP_LOW_Pin);
|
||||
//Make two D- pins floating
|
||||
QC_DM_PullDown();
|
||||
}
|
||||
void QC_Post_Probe_En() {
|
||||
//Make two D- pins outputs
|
||||
gpio_init(QC_DM_LOW_GPIO_Port, GPIO_MODE_OUT_PP, GPIO_OSPEED_2MHZ, QC_DM_LOW_Pin);
|
||||
gpio_init(QC_DM_HIGH_GPIO_Port, GPIO_MODE_OUT_PP, GPIO_OSPEED_2MHZ, QC_DM_HIGH_Pin);
|
||||
|
||||
}
|
||||
|
||||
uint8_t QC_DM_PulledDown() {
|
||||
return gpio_input_bit_get(USB_DM_LOW_GPIO_Port, USB_DM_Pin) == RESET ? 1 : 0;
|
||||
}
|
||||
#endif
|
||||
void QC_resync() {
|
||||
#ifdef POW_QC
|
||||
uint8_t targetvoltage = 90;
|
||||
if (systemSettings.QCIdealVoltage == 1) {
|
||||
targetvoltage = 120;
|
||||
} else if (systemSettings.QCIdealVoltage == 2) {
|
||||
targetvoltage = 200;
|
||||
}
|
||||
|
||||
seekQC(targetvoltage, systemSettings.voltageDiv); // Run the QC seek again if we have drifted too much
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user