Reformat
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
#include <IRQ.h>
|
||||
|
||||
const uint16_t powerPWM = 255;
|
||||
const uint8_t holdoffTicks = 13; // delay of 7 ms
|
||||
const uint8_t tempMeasureTicks = 17;
|
||||
const uint8_t holdoffTicks = 25; // delay of 7 ms
|
||||
const uint8_t tempMeasureTicks = 25;
|
||||
|
||||
uint16_t totalPWM; // htim2.Init.Period, the full PWM cycle
|
||||
|
||||
@@ -23,7 +23,7 @@ void resetWatchdog() {
|
||||
}
|
||||
|
||||
uint16_t getTipInstantTemperature() {
|
||||
uint16_t sum = 0; // 12 bit readings * 8 -> 15 bits
|
||||
volatile uint16_t sum = 0; // 12 bit readings * 8*2 -> 16 bits
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
sum += adc_inserted_data_read(ADC0, i);
|
||||
@@ -91,7 +91,8 @@ uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample) {
|
||||
void unstick_I2C() {
|
||||
/* configure SDA/SCL for GPIO */
|
||||
GPIO_BC(GPIOB) |= SDA_Pin | SCL_Pin;
|
||||
gpio_init(SDA_GPIO_Port, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ, SDA_Pin | SCL_Pin);
|
||||
gpio_init(SDA_GPIO_Port, GPIO_MODE_OUT_PP, GPIO_OSPEED_50MHZ,
|
||||
SDA_Pin | SCL_Pin);
|
||||
asm("nop");
|
||||
asm("nop");
|
||||
asm("nop");
|
||||
@@ -106,7 +107,8 @@ void unstick_I2C() {
|
||||
GPIO_BOP(GPIOB) |= SDA_Pin;
|
||||
/* connect PB6 to I2C0_SCL */
|
||||
/* connect PB7 to I2C0_SDA */
|
||||
gpio_init(SDA_GPIO_Port, GPIO_MODE_AF_OD, GPIO_OSPEED_50MHZ, SDA_Pin | SCL_Pin);
|
||||
gpio_init(SDA_GPIO_Port, GPIO_MODE_AF_OD, GPIO_OSPEED_50MHZ,
|
||||
SDA_Pin | SCL_Pin);
|
||||
}
|
||||
|
||||
uint8_t getButtonA() {
|
||||
@@ -122,8 +124,4 @@ void reboot() {
|
||||
}
|
||||
}
|
||||
|
||||
void delay_ms(uint16_t count) {
|
||||
delay_1ms(count);
|
||||
}
|
||||
|
||||
|
||||
void delay_ms(uint16_t count) { delay_1ms(count); }
|
||||
|
||||
@@ -25,7 +25,8 @@ uint8_t FRToSI2C::I2C_RegisterRead(uint8_t add, uint8_t reg) {
|
||||
return temp;
|
||||
}
|
||||
|
||||
bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t read_address, uint8_t *p_buffer, uint16_t number_of_byte) {
|
||||
bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t read_address,
|
||||
uint8_t *p_buffer, uint16_t number_of_byte) {
|
||||
if (!lock())
|
||||
return false;
|
||||
i2c_interrupt_disable(I2C0, I2C_INT_ERR);
|
||||
@@ -60,7 +61,8 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t read_address, uint8_t *p_b
|
||||
/* enable acknowledge */
|
||||
i2c_ack_config(I2C0, I2C_ACK_ENABLE);
|
||||
/* i2c master sends start signal only when the bus is idle */
|
||||
while (i2c_flag_get(I2C0, I2C_FLAG_I2CBSY) && (timeout < I2C_TIME_OUT )) {
|
||||
while (i2c_flag_get(I2C0, I2C_FLAG_I2CBSY) &&
|
||||
(timeout < I2C_TIME_OUT)) {
|
||||
timeout++;
|
||||
}
|
||||
if (timeout < I2C_TIME_OUT) {
|
||||
@@ -81,7 +83,8 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t read_address, uint8_t *p_b
|
||||
break;
|
||||
case I2C_SEND_ADDRESS:
|
||||
/* i2c master sends START signal successfully */
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) && (timeout < I2C_TIME_OUT )) {
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) &&
|
||||
(timeout < I2C_TIME_OUT)) {
|
||||
timeout++;
|
||||
}
|
||||
if (timeout < I2C_TIME_OUT) {
|
||||
@@ -101,7 +104,8 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t read_address, uint8_t *p_b
|
||||
break;
|
||||
case I2C_CLEAR_ADDRESS_FLAG:
|
||||
/* address flag set means i2c slave sends ACK */
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND)) && (timeout < I2C_TIME_OUT )) {
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND)) &&
|
||||
(timeout < I2C_TIME_OUT)) {
|
||||
timeout++;
|
||||
if (i2c_flag_get(I2C0, I2C_FLAG_AERR)) {
|
||||
i2c_flag_clear(I2C0, I2C_FLAG_AERR);
|
||||
@@ -133,7 +137,8 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t read_address, uint8_t *p_b
|
||||
case I2C_TRANSMIT_DATA:
|
||||
if (0 == in_rx_cycle) {
|
||||
/* wait until the transmit data buffer is empty */
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_TBE)) && (timeout < I2C_TIME_OUT )) {
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_TBE)) &&
|
||||
(timeout < I2C_TIME_OUT)) {
|
||||
timeout++;
|
||||
}
|
||||
if (timeout < I2C_TIME_OUT) {
|
||||
@@ -146,7 +151,8 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t read_address, uint8_t *p_b
|
||||
in_rx_cycle = 0;
|
||||
}
|
||||
/* wait until BTC bit is set */
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_BTC)) && (timeout < I2C_TIME_OUT )) {
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_BTC)) &&
|
||||
(timeout < I2C_TIME_OUT)) {
|
||||
timeout++;
|
||||
}
|
||||
if (timeout < I2C_TIME_OUT) {
|
||||
@@ -163,7 +169,8 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t read_address, uint8_t *p_b
|
||||
if (number_of_byte < 2) {
|
||||
/* disable acknowledge */
|
||||
i2c_ack_config(I2C0, I2C_ACK_DISABLE);
|
||||
/* clear ADDSEND register by reading I2C_STAT0 then I2C_STAT1 register (I2C_STAT0 has already been read) */
|
||||
/* clear ADDSEND register by reading I2C_STAT0 then I2C_STAT1 register
|
||||
* (I2C_STAT0 has already been read) */
|
||||
i2c_flag_get(I2C0, I2C_FLAG_ADDSEND);
|
||||
/* send a stop condition to I2C bus*/
|
||||
i2c_stop_on_bus(I2C0);
|
||||
@@ -231,7 +238,8 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t read_address, uint8_t *p_b
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint8_t *p_buffer, uint16_t number_of_byte) {
|
||||
bool FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
|
||||
uint8_t *p_buffer, uint16_t number_of_byte) {
|
||||
if (!lock())
|
||||
return false;
|
||||
|
||||
@@ -263,7 +271,8 @@ bool FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint8_t *p_bu
|
||||
break;
|
||||
case I2C_SEND_ADDRESS:
|
||||
/* i2c master sends START signal successfully */
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) && (timeout < I2C_TIME_OUT )) {
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) &&
|
||||
(timeout < I2C_TIME_OUT)) {
|
||||
timeout++;
|
||||
}
|
||||
if (timeout < I2C_TIME_OUT) {
|
||||
@@ -279,7 +288,8 @@ bool FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint8_t *p_bu
|
||||
break;
|
||||
case I2C_CLEAR_ADDRESS_FLAG:
|
||||
/* address flag set means i2c slave sends ACK */
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND)) && (timeout < I2C_TIME_OUT )) {
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND)) &&
|
||||
(timeout < I2C_TIME_OUT)) {
|
||||
timeout++;
|
||||
if (i2c_flag_get(I2C0, I2C_FLAG_AERR)) {
|
||||
i2c_flag_clear(I2C0, I2C_FLAG_AERR);
|
||||
@@ -314,7 +324,8 @@ bool FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint8_t *p_bu
|
||||
timeout++;
|
||||
}
|
||||
if (timeout < I2C_TIME_OUT) {
|
||||
/* send the EEPROM's internal address to write to : only one byte address */
|
||||
/* send the EEPROM's internal address to write to : only one byte
|
||||
* address */
|
||||
i2c_data_transmit(I2C0, MemAddress);
|
||||
timeout = 0;
|
||||
} else {
|
||||
@@ -386,9 +397,7 @@ bool FRToSI2C::probe(uint16_t DevAddress) {
|
||||
return Mem_Read(DevAddress, 0x00, temp, sizeof(temp));
|
||||
}
|
||||
|
||||
void FRToSI2C::I2C_Unstick() {
|
||||
unstick_I2C();
|
||||
}
|
||||
void FRToSI2C::I2C_Unstick() { unstick_I2C(); }
|
||||
|
||||
bool FRToSI2C::lock() {
|
||||
if (I2CSemaphore == nullptr) {
|
||||
@@ -397,13 +406,14 @@ bool FRToSI2C::lock() {
|
||||
return xSemaphoreTake(I2CSemaphore, 1000) == pdTRUE;
|
||||
}
|
||||
|
||||
void FRToSI2C::unlock() {
|
||||
xSemaphoreGive(I2CSemaphore);
|
||||
}
|
||||
void FRToSI2C::unlock() { xSemaphoreGive(I2CSemaphore); }
|
||||
|
||||
bool FRToSI2C::writeRegistersBulk(const uint8_t address, const I2C_REG *registers, const uint8_t registersLength) {
|
||||
bool FRToSI2C::writeRegistersBulk(const uint8_t address,
|
||||
const I2C_REG *registers,
|
||||
const uint8_t registersLength) {
|
||||
for (int index = 0; index < registersLength; index++) {
|
||||
if (!I2C_RegisterWrite(address, registers[index].reg, registers[index].val)) {
|
||||
if (!I2C_RegisterWrite(address, registers[index].reg,
|
||||
registers[index].val)) {
|
||||
return false;
|
||||
}
|
||||
if (registers[index].pause_ms) {
|
||||
@@ -421,7 +431,6 @@ bool FRToSI2C::wakePart(uint16_t DevAddress) {
|
||||
i2c_interrupt_disable(I2C0, I2C_INT_ERR);
|
||||
i2c_interrupt_disable(I2C0, I2C_INT_EV);
|
||||
i2c_interrupt_disable(I2C0, I2C_INT_BUF);
|
||||
dma_parameter_struct dma_init_struct;
|
||||
|
||||
uint8_t state = I2C_START;
|
||||
uint16_t timeout = 0;
|
||||
@@ -446,7 +455,8 @@ bool FRToSI2C::wakePart(uint16_t DevAddress) {
|
||||
break;
|
||||
case I2C_SEND_ADDRESS:
|
||||
/* i2c master sends START signal successfully */
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) && (timeout < I2C_TIME_OUT )) {
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_SBSEND)) &&
|
||||
(timeout < I2C_TIME_OUT)) {
|
||||
timeout++;
|
||||
}
|
||||
if (timeout < I2C_TIME_OUT) {
|
||||
@@ -462,7 +472,8 @@ bool FRToSI2C::wakePart(uint16_t DevAddress) {
|
||||
break;
|
||||
case I2C_CLEAR_ADDRESS_FLAG:
|
||||
/* address flag set means i2c slave sends ACK */
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND)) && (timeout < I2C_TIME_OUT )) {
|
||||
while ((!i2c_flag_get(I2C0, I2C_FLAG_ADDSEND)) &&
|
||||
(timeout < I2C_TIME_OUT)) {
|
||||
timeout++;
|
||||
if (i2c_flag_get(I2C0, I2C_FLAG_AERR)) {
|
||||
i2c_flag_clear(I2C0, I2C_FLAG_AERR);
|
||||
|
||||
@@ -8,11 +8,13 @@
|
||||
#include "BSP.h"
|
||||
#include "Pins.h"
|
||||
#include "gd32vf103.h"
|
||||
#include <string.h>
|
||||
#include "systick.h"
|
||||
#include <string.h>
|
||||
#define ADC_NORM_CHANNELS 2
|
||||
#define ADC_NORM_SAMPLES 32
|
||||
uint16_t ADCReadings[ADC_NORM_SAMPLES * ADC_NORM_CHANNELS]; // room for 32 lots of the pair of readings
|
||||
uint16_t
|
||||
ADCReadings[ADC_NORM_SAMPLES *
|
||||
ADC_NORM_CHANNELS]; // room for 32 lots of the pair of readings
|
||||
|
||||
// Functions
|
||||
void setup_gpio();
|
||||
@@ -23,7 +25,6 @@ void setup_timers();
|
||||
void setup_iwdg();
|
||||
|
||||
void hardware_init() {
|
||||
|
||||
// GPIO
|
||||
setup_gpio();
|
||||
// DMA
|
||||
@@ -65,15 +66,14 @@ void setup_gpio() {
|
||||
gpio_init(OLED_RESET_GPIO_Port, GPIO_MODE_OUT_PP, GPIO_OSPEED_2MHZ,
|
||||
OLED_RESET_Pin);
|
||||
// I2C as AF Open Drain
|
||||
gpio_init(SDA_GPIO_Port, GPIO_MODE_AF_OD, GPIO_OSPEED_50MHZ, SDA_Pin | SCL_Pin);
|
||||
gpio_init(SDA_GPIO_Port, GPIO_MODE_AF_OD, GPIO_OSPEED_50MHZ,
|
||||
SDA_Pin | SCL_Pin);
|
||||
// PWM output as AF Push Pull
|
||||
gpio_init(PWM_Out_GPIO_Port, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ,
|
||||
PWM_Out_Pin);
|
||||
gpio_init(PWM_Out_GPIO_Port, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, PWM_Out_Pin);
|
||||
// Analog Inputs ... as analog inputs
|
||||
gpio_init(TMP36_INPUT_GPIO_Port, GPIO_MODE_AIN, GPIO_OSPEED_50MHZ,
|
||||
TMP36_INPUT_Pin);
|
||||
gpio_init(TIP_TEMP_GPIO_Port, GPIO_MODE_AIN, GPIO_OSPEED_50MHZ,
|
||||
TIP_TEMP_Pin);
|
||||
gpio_init(TIP_TEMP_GPIO_Port, GPIO_MODE_AIN, GPIO_OSPEED_50MHZ, TIP_TEMP_Pin);
|
||||
gpio_init(VIN_GPIO_Port, GPIO_MODE_AIN, GPIO_OSPEED_50MHZ, VIN_Pin);
|
||||
|
||||
// Remap PB4 away from JTAG NJRST
|
||||
@@ -148,23 +148,33 @@ void setup_adc() {
|
||||
adc_channel_length_config(ADC0, ADC_REGULAR_CHANNEL, ADC_NORM_CHANNELS);
|
||||
adc_channel_length_config(ADC1, ADC_REGULAR_CHANNEL, ADC_NORM_CHANNELS);
|
||||
// Setup the two channels
|
||||
adc_regular_channel_config(ADC0, 0, TMP36_ADC0_CHANNEL, ADC_SAMPLETIME_71POINT5); //temp sensor
|
||||
adc_regular_channel_config(ADC1, 0, TMP36_ADC1_CHANNEL, ADC_SAMPLETIME_71POINT5); //temp sensor
|
||||
adc_regular_channel_config(ADC0, 1, VIN_ADC0_CHANNEL, ADC_SAMPLETIME_71POINT5); //DC Input voltage
|
||||
adc_regular_channel_config(ADC1, 1, VIN_ADC1_CHANNEL, ADC_SAMPLETIME_71POINT5); //DC Input voltage
|
||||
adc_regular_channel_config(ADC0, 0, TMP36_ADC0_CHANNEL,
|
||||
ADC_SAMPLETIME_71POINT5); // temp sensor
|
||||
adc_regular_channel_config(ADC1, 0, TMP36_ADC1_CHANNEL,
|
||||
ADC_SAMPLETIME_71POINT5); // temp sensor
|
||||
adc_regular_channel_config(ADC0, 1, VIN_ADC0_CHANNEL,
|
||||
ADC_SAMPLETIME_71POINT5); // DC Input voltage
|
||||
adc_regular_channel_config(ADC1, 1, VIN_ADC1_CHANNEL,
|
||||
ADC_SAMPLETIME_71POINT5); // DC Input voltage
|
||||
// Setup that we want all 4 inserted readings to be the tip temp
|
||||
adc_channel_length_config(ADC0, ADC_INSERTED_CHANNEL, 4);
|
||||
adc_channel_length_config(ADC1, ADC_INSERTED_CHANNEL, 4);
|
||||
for (int rank = 0; rank < 4; rank++) {
|
||||
adc_inserted_channel_config(ADC0, rank, TIP_TEMP_ADC0_CHANNEL, ADC_SAMPLETIME_1POINT5);
|
||||
adc_inserted_channel_config(ADC1, rank, TIP_TEMP_ADC1_CHANNEL, ADC_SAMPLETIME_1POINT5);
|
||||
adc_inserted_channel_config(ADC0, rank, TIP_TEMP_ADC0_CHANNEL,
|
||||
ADC_SAMPLETIME_1POINT5);
|
||||
adc_inserted_channel_config(ADC1, rank, TIP_TEMP_ADC1_CHANNEL,
|
||||
ADC_SAMPLETIME_1POINT5);
|
||||
}
|
||||
// Setup timer 1 channel 0 to trigger injected measurements
|
||||
adc_external_trigger_source_config(ADC0, ADC_INSERTED_CHANNEL, ADC0_1_EXTTRIG_INSERTED_T1_CH0);
|
||||
adc_external_trigger_source_config(ADC1, ADC_INSERTED_CHANNEL, ADC0_1_EXTTRIG_INSERTED_T1_CH0);
|
||||
adc_external_trigger_source_config(ADC0, ADC_INSERTED_CHANNEL,
|
||||
ADC0_1_EXTTRIG_INSERTED_T1_CH0);
|
||||
adc_external_trigger_source_config(ADC1, ADC_INSERTED_CHANNEL,
|
||||
ADC0_1_EXTTRIG_INSERTED_T1_CH0);
|
||||
|
||||
adc_external_trigger_source_config(ADC0, ADC_REGULAR_CHANNEL, ADC0_1_EXTTRIG_REGULAR_NONE);
|
||||
adc_external_trigger_source_config(ADC1, ADC_REGULAR_CHANNEL, ADC0_1_EXTTRIG_REGULAR_NONE);
|
||||
adc_external_trigger_source_config(ADC0, ADC_REGULAR_CHANNEL,
|
||||
ADC0_1_EXTTRIG_REGULAR_NONE);
|
||||
adc_external_trigger_source_config(ADC1, ADC_REGULAR_CHANNEL,
|
||||
ADC0_1_EXTTRIG_REGULAR_NONE);
|
||||
// Enable triggers for the ADC
|
||||
adc_external_trigger_config(ADC0, ADC_INSERTED_CHANNEL, ENABLE);
|
||||
adc_external_trigger_config(ADC1, ADC_INSERTED_CHANNEL, ENABLE);
|
||||
@@ -179,12 +189,9 @@ void setup_adc() {
|
||||
adc_oversample_mode_disable(ADC0);
|
||||
adc_oversample_mode_disable(ADC1);
|
||||
adc_enable(ADC0);
|
||||
delay_1ms(1);
|
||||
adc_calibration_enable(ADC0);
|
||||
adc_enable(ADC1);
|
||||
delay_1ms(1);
|
||||
adc_calibration_enable(ADC1);
|
||||
delay_1ms(1);
|
||||
adc_dma_mode_enable(ADC0);
|
||||
// Enable interrupt on end of injected readings
|
||||
adc_interrupt_flag_clear(ADC0, ADC_INT_FLAG_EOC);
|
||||
@@ -222,9 +229,9 @@ void setup_timers() {
|
||||
timer_ocintpara.outputstate = TIMER_CCX_ENABLE;
|
||||
timer_channel_output_config(TIMER1, TIMER_CH_0, &timer_ocintpara);
|
||||
|
||||
timer_channel_output_pulse_value_config(TIMER1, TIMER_CH_0, powerPWM + holdoffTicks);
|
||||
timer_channel_output_mode_config(TIMER1, TIMER_CH_0,
|
||||
TIMER_OC_MODE_PWM1);
|
||||
timer_channel_output_pulse_value_config(TIMER1, TIMER_CH_0,
|
||||
powerPWM + holdoffTicks);
|
||||
timer_channel_output_mode_config(TIMER1, TIMER_CH_0, TIMER_OC_MODE_PWM1);
|
||||
timer_channel_output_shadow_config(TIMER1, TIMER_CH_0,
|
||||
TIMER_OC_SHADOW_DISABLE);
|
||||
/* CH1 used for irq */
|
||||
@@ -234,14 +241,12 @@ void setup_timers() {
|
||||
timer_channel_output_config(TIMER1, TIMER_CH_1, &timer_ocintpara);
|
||||
|
||||
timer_channel_output_pulse_value_config(TIMER1, TIMER_CH_1, 0);
|
||||
timer_channel_output_mode_config(TIMER1, TIMER_CH_1,
|
||||
TIMER_OC_MODE_PWM0);
|
||||
timer_channel_output_mode_config(TIMER1, TIMER_CH_1, TIMER_OC_MODE_PWM0);
|
||||
timer_channel_output_shadow_config(TIMER1, TIMER_CH_1,
|
||||
TIMER_OC_SHADOW_DISABLE);
|
||||
// IRQ
|
||||
timer_interrupt_enable(TIMER1, TIMER_INT_UP);
|
||||
timer_interrupt_enable(TIMER1, TIMER_INT_CH1);
|
||||
|
||||
}
|
||||
|
||||
eclic_irq_enable(TIMER1_IRQn, 2, 5);
|
||||
@@ -269,8 +274,7 @@ void setup_timers() {
|
||||
timer_ocintpara.ocnidlestate = TIMER_OCN_IDLE_STATE_LOW;
|
||||
timer_channel_output_config(TIMER2, TIMER_CH_0, &timer_ocintpara);
|
||||
timer_channel_output_pulse_value_config(TIMER2, TIMER_CH_0, 50);
|
||||
timer_channel_output_mode_config(TIMER2, TIMER_CH_0,
|
||||
TIMER_OC_MODE_PWM0);
|
||||
timer_channel_output_mode_config(TIMER2, TIMER_CH_0, TIMER_OC_MODE_PWM0);
|
||||
timer_channel_output_shadow_config(TIMER2, TIMER_CH_0,
|
||||
TIMER_OC_SHADOW_DISABLE);
|
||||
timer_auto_reload_shadow_enable(TIMER2);
|
||||
@@ -283,7 +287,8 @@ void setup_iwdg() {
|
||||
|
||||
void setupFUSBIRQ() {
|
||||
// Setup IRQ for USB-PD
|
||||
gpio_init(FUSB302_IRQ_GPIO_Port, GPIO_MODE_IPU, GPIO_OSPEED_2MHZ, FUSB302_IRQ_Pin);
|
||||
gpio_init(FUSB302_IRQ_GPIO_Port, GPIO_MODE_IPU, GPIO_OSPEED_2MHZ,
|
||||
FUSB302_IRQ_Pin);
|
||||
eclic_irq_enable(EXTI5_9_IRQn, 1, 1);
|
||||
/* connect key EXTI line to key GPIO pin */
|
||||
gpio_exti_source_select(GPIO_PORT_SOURCE_GPIOB, GPIO_PIN_SOURCE_5);
|
||||
|
||||
Reference in New Issue
Block a user