|
|
|
|
@@ -62,23 +62,23 @@
|
|
|
|
|
/* add user code end 0 */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief system clock config program
|
|
|
|
|
* @note the system clock is configured as follow:
|
|
|
|
|
* system clock (sclk) = hick / 12 * pll_mult
|
|
|
|
|
* system clock source = HICK_VALUE
|
|
|
|
|
* - hext = HEXT_VALUE
|
|
|
|
|
* - sclk = 240000000
|
|
|
|
|
* - ahbdiv = 1
|
|
|
|
|
* - ahbclk = 240000000
|
|
|
|
|
* - apb1div = 2
|
|
|
|
|
* - apb1clk = 120000000
|
|
|
|
|
* - apb2div = 2
|
|
|
|
|
* - apb2clk = 120000000
|
|
|
|
|
* - pll_mult = 60
|
|
|
|
|
* - pll_range = GT72MHZ (greater than 72 mhz)
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief system clock config program
|
|
|
|
|
* @note the system clock is configured as follow:
|
|
|
|
|
* system clock (sclk) = hick / 12 * pll_mult
|
|
|
|
|
* system clock source = HICK_VALUE
|
|
|
|
|
* - hext = HEXT_VALUE
|
|
|
|
|
* - sclk = 240000000
|
|
|
|
|
* - ahbdiv = 1
|
|
|
|
|
* - ahbclk = 240000000
|
|
|
|
|
* - apb1div = 2
|
|
|
|
|
* - apb1clk = 120000000
|
|
|
|
|
* - apb2div = 2
|
|
|
|
|
* - apb2clk = 120000000
|
|
|
|
|
* - pll_mult = 60
|
|
|
|
|
* - pll_range = GT72MHZ (greater than 72 mhz)
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_system_clock_config(void)
|
|
|
|
|
{
|
|
|
|
|
/* reset crm */
|
|
|
|
|
@@ -88,21 +88,24 @@ void wk_system_clock_config(void)
|
|
|
|
|
crm_clock_source_enable(CRM_CLOCK_SOURCE_LICK, TRUE);
|
|
|
|
|
|
|
|
|
|
/* wait till lick is ready */
|
|
|
|
|
while (crm_flag_get(CRM_LICK_STABLE_FLAG) != SET) {
|
|
|
|
|
while(crm_flag_get(CRM_LICK_STABLE_FLAG) != SET)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* enable hext */
|
|
|
|
|
crm_clock_source_enable(CRM_CLOCK_SOURCE_HEXT, TRUE);
|
|
|
|
|
|
|
|
|
|
/* wait till hext is ready */
|
|
|
|
|
while (crm_hext_stable_wait() == ERROR) {
|
|
|
|
|
while(crm_hext_stable_wait() == ERROR)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* enable hick */
|
|
|
|
|
crm_clock_source_enable(CRM_CLOCK_SOURCE_HICK, TRUE);
|
|
|
|
|
|
|
|
|
|
/* wait till hick is ready */
|
|
|
|
|
while (crm_flag_get(CRM_HICK_STABLE_FLAG) != SET) {
|
|
|
|
|
while(crm_flag_get(CRM_HICK_STABLE_FLAG) != SET)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* config pll clock resource */
|
|
|
|
|
@@ -112,7 +115,8 @@ void wk_system_clock_config(void)
|
|
|
|
|
crm_clock_source_enable(CRM_CLOCK_SOURCE_PLL, TRUE);
|
|
|
|
|
|
|
|
|
|
/* wait till pll is ready */
|
|
|
|
|
while (crm_flag_get(CRM_PLL_STABLE_FLAG) != SET) {
|
|
|
|
|
while(crm_flag_get(CRM_PLL_STABLE_FLAG) != SET)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* config ahbclk */
|
|
|
|
|
@@ -131,7 +135,8 @@ void wk_system_clock_config(void)
|
|
|
|
|
crm_sysclk_switch(CRM_SCLK_PLL);
|
|
|
|
|
|
|
|
|
|
/* wait till pll is used as system clock source */
|
|
|
|
|
while (crm_sysclk_switch_status_get() != CRM_SCLK_PLL) {
|
|
|
|
|
while(crm_sysclk_switch_status_get() != CRM_SCLK_PLL)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* disable auto step mode */
|
|
|
|
|
@@ -142,12 +147,15 @@ void wk_system_clock_config(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief config periph clock
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief config periph clock
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_periph_clock_config(void)
|
|
|
|
|
{
|
|
|
|
|
/* enable crc periph clock */
|
|
|
|
|
crm_periph_clock_enable(CRM_CRC_PERIPH_CLOCK, TRUE);
|
|
|
|
|
|
|
|
|
|
/* enable iomux periph clock */
|
|
|
|
|
crm_periph_clock_enable(CRM_IOMUX_PERIPH_CLOCK, TRUE);
|
|
|
|
|
|
|
|
|
|
@@ -163,9 +171,6 @@ void wk_periph_clock_config(void)
|
|
|
|
|
/* enable gpiod periph clock */
|
|
|
|
|
crm_periph_clock_enable(CRM_GPIOD_PERIPH_CLOCK, TRUE);
|
|
|
|
|
|
|
|
|
|
/* enable adc1 periph clock */
|
|
|
|
|
crm_periph_clock_enable(CRM_ADC1_PERIPH_CLOCK, TRUE);
|
|
|
|
|
|
|
|
|
|
/* enable tmr8 periph clock */
|
|
|
|
|
crm_periph_clock_enable(CRM_TMR8_PERIPH_CLOCK, TRUE);
|
|
|
|
|
|
|
|
|
|
@@ -201,10 +206,10 @@ void wk_periph_clock_config(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief init debug function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief init debug function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_debug_config(void)
|
|
|
|
|
{
|
|
|
|
|
/* jtag-dp disabled and sw-dp enabled */
|
|
|
|
|
@@ -212,10 +217,10 @@ void wk_debug_config(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief nvic config
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief nvic config
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_nvic_config(void)
|
|
|
|
|
{
|
|
|
|
|
nvic_priority_group_config(NVIC_PRIORITY_GROUP_4);
|
|
|
|
|
@@ -229,10 +234,10 @@ void wk_nvic_config(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief init gpio_input/gpio_output/gpio_analog/eventout function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief init gpio_input/gpio_output/gpio_analog/eventout function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_gpio_config(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin gpio_config 0 */
|
|
|
|
|
@@ -266,10 +271,10 @@ void wk_gpio_config(void)
|
|
|
|
|
gpio_bits_reset(GPIOC, GPIO_PINS_0 | GPIO_PINS_1 | GPIO_PINS_2 | GPIO_PINS_3);
|
|
|
|
|
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_OUTPUT;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_0 | GPIO_PINS_1 | GPIO_PINS_2 | GPIO_PINS_3;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_OUTPUT;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_0 | GPIO_PINS_1 | GPIO_PINS_2 | GPIO_PINS_3;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init(GPIOC, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* add user code begin gpio_config 2 */
|
|
|
|
|
@@ -278,10 +283,10 @@ void wk_gpio_config(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief init i2c1 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief init i2c1 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_i2c1_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin i2c1_init 0 */
|
|
|
|
|
@@ -297,19 +302,19 @@ void wk_i2c1_init(void)
|
|
|
|
|
/* add user code end i2c1_init 1 */
|
|
|
|
|
|
|
|
|
|
/* configure the SCL pin */
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_6;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_6;
|
|
|
|
|
gpio_init(GPIOB, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* configure the SDA pin */
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_7;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_7;
|
|
|
|
|
gpio_init(GPIOB, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
i2c_init(I2C1, I2C_FSMODE_DUTY_2_1, 100000);
|
|
|
|
|
@@ -326,10 +331,10 @@ void wk_i2c1_init(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief init i2c2 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief init i2c2 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_i2c2_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin i2c2_init 0 */
|
|
|
|
|
@@ -343,21 +348,21 @@ void wk_i2c2_init(void)
|
|
|
|
|
/* add user code begin i2c2_init 1 */
|
|
|
|
|
|
|
|
|
|
/* add user code end i2c2_init 1 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* configure the SCL pin */
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_10;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_10;
|
|
|
|
|
gpio_init(GPIOB, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* configure the SDA pin */
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_OPEN_DRAIN;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_11;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_11;
|
|
|
|
|
gpio_init(GPIOB, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
i2c_init(I2C2, I2C_FSMODE_DUTY_2_1, 100000);
|
|
|
|
|
@@ -374,10 +379,10 @@ void wk_i2c2_init(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief init usart1 function
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief init usart1 function
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_usart1_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin usart1_init 0 */
|
|
|
|
|
@@ -393,18 +398,18 @@ void wk_usart1_init(void)
|
|
|
|
|
|
|
|
|
|
/* configure the TX pin */
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_9;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_9;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init(GPIOA, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* configure the RX pin */
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_INPUT;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_10;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_INPUT;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_10;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init(GPIOA, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* configure param */
|
|
|
|
|
@@ -431,10 +436,10 @@ void wk_usart1_init(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief init usart2 function
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief init usart2 function
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_usart2_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin usart2_init 0 */
|
|
|
|
|
@@ -450,18 +455,18 @@ void wk_usart2_init(void)
|
|
|
|
|
|
|
|
|
|
/* configure the TX pin */
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_2;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_2;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init(GPIOA, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* configure the RX pin */
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_INPUT;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_3;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_INPUT;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_3;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init(GPIOA, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* configure param */
|
|
|
|
|
@@ -488,10 +493,10 @@ void wk_usart2_init(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief init usart3 function
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief init usart3 function
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_usart3_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin usart3_init 0 */
|
|
|
|
|
@@ -507,18 +512,18 @@ void wk_usart3_init(void)
|
|
|
|
|
|
|
|
|
|
/* configure the TX pin */
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_10;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_10;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init(GPIOC, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* configure the RX pin */
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_INPUT;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_11;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_INPUT;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_11;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init(GPIOC, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
gpio_pin_remap_config(USART3_GMUX_0001, TRUE);
|
|
|
|
|
@@ -547,10 +552,10 @@ void wk_usart3_init(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief init tmr6 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief init tmr6 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_tmr6_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin tmr6_init 0 */
|
|
|
|
|
@@ -585,10 +590,10 @@ void wk_tmr6_init(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief init tmr8 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief init tmr8 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_tmr8_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin tmr8_init 0 */
|
|
|
|
|
@@ -606,34 +611,34 @@ void wk_tmr8_init(void)
|
|
|
|
|
/* add user code end tmr8_init 1 */
|
|
|
|
|
|
|
|
|
|
/* configure the CH1 pin */
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_6;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_6;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init(GPIOC, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* configure the CH2 pin */
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_7;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_7;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init(GPIOC, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* configure the CH3 pin */
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_8;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_8;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init(GPIOC, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* configure the CH4 pin */
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_9;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_9;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init(GPIOC, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
@@ -649,63 +654,64 @@ void wk_tmr8_init(void)
|
|
|
|
|
tmr_primary_mode_select(TMR8, TMR_PRIMARY_SEL_RESET);
|
|
|
|
|
|
|
|
|
|
/* configure channel 1 output settings */
|
|
|
|
|
tmr_output_struct.oc_mode = TMR_OUTPUT_CONTROL_OFF;
|
|
|
|
|
tmr_output_struct.oc_output_state = TRUE;
|
|
|
|
|
tmr_output_struct.oc_mode = TMR_OUTPUT_CONTROL_OFF;
|
|
|
|
|
tmr_output_struct.oc_output_state = TRUE;
|
|
|
|
|
tmr_output_struct.occ_output_state = FALSE;
|
|
|
|
|
tmr_output_struct.oc_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.occ_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.oc_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.occ_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.oc_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.occ_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.oc_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.occ_idle_state = FALSE;
|
|
|
|
|
tmr_output_channel_config(TMR8, TMR_SELECT_CHANNEL_1, &tmr_output_struct);
|
|
|
|
|
tmr_channel_value_set(TMR8, TMR_SELECT_CHANNEL_1, 0);
|
|
|
|
|
tmr_output_channel_buffer_enable(TMR8, TMR_SELECT_CHANNEL_1, FALSE);
|
|
|
|
|
|
|
|
|
|
/* configure channel 2 output settings */
|
|
|
|
|
tmr_output_struct.oc_mode = TMR_OUTPUT_CONTROL_OFF;
|
|
|
|
|
tmr_output_struct.oc_output_state = TRUE;
|
|
|
|
|
tmr_output_struct.oc_mode = TMR_OUTPUT_CONTROL_OFF;
|
|
|
|
|
tmr_output_struct.oc_output_state = TRUE;
|
|
|
|
|
tmr_output_struct.occ_output_state = FALSE;
|
|
|
|
|
tmr_output_struct.oc_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.occ_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.oc_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.occ_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.oc_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.occ_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.oc_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.occ_idle_state = FALSE;
|
|
|
|
|
tmr_output_channel_config(TMR8, TMR_SELECT_CHANNEL_2, &tmr_output_struct);
|
|
|
|
|
tmr_channel_value_set(TMR8, TMR_SELECT_CHANNEL_2, 0);
|
|
|
|
|
tmr_output_channel_buffer_enable(TMR8, TMR_SELECT_CHANNEL_2, FALSE);
|
|
|
|
|
|
|
|
|
|
/* configure channel 3 output settings */
|
|
|
|
|
tmr_output_struct.oc_mode = TMR_OUTPUT_CONTROL_OFF;
|
|
|
|
|
tmr_output_struct.oc_output_state = TRUE;
|
|
|
|
|
tmr_output_struct.oc_mode = TMR_OUTPUT_CONTROL_OFF;
|
|
|
|
|
tmr_output_struct.oc_output_state = TRUE;
|
|
|
|
|
tmr_output_struct.occ_output_state = FALSE;
|
|
|
|
|
tmr_output_struct.oc_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.occ_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.oc_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.occ_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.oc_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.occ_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.oc_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.occ_idle_state = FALSE;
|
|
|
|
|
tmr_output_channel_config(TMR8, TMR_SELECT_CHANNEL_3, &tmr_output_struct);
|
|
|
|
|
tmr_channel_value_set(TMR8, TMR_SELECT_CHANNEL_3, 0);
|
|
|
|
|
tmr_output_channel_buffer_enable(TMR8, TMR_SELECT_CHANNEL_3, FALSE);
|
|
|
|
|
|
|
|
|
|
/* configure channel 4 output settings */
|
|
|
|
|
tmr_output_struct.oc_mode = TMR_OUTPUT_CONTROL_OFF;
|
|
|
|
|
tmr_output_struct.oc_output_state = TRUE;
|
|
|
|
|
tmr_output_struct.oc_mode = TMR_OUTPUT_CONTROL_OFF;
|
|
|
|
|
tmr_output_struct.oc_output_state = TRUE;
|
|
|
|
|
tmr_output_struct.occ_output_state = FALSE;
|
|
|
|
|
tmr_output_struct.oc_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.occ_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.oc_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.occ_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.oc_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.occ_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.oc_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.occ_idle_state = FALSE;
|
|
|
|
|
tmr_output_channel_config(TMR8, TMR_SELECT_CHANNEL_4, &tmr_output_struct);
|
|
|
|
|
tmr_channel_value_set(TMR8, TMR_SELECT_CHANNEL_4, 0);
|
|
|
|
|
tmr_output_channel_buffer_enable(TMR8, TMR_SELECT_CHANNEL_4, FALSE);
|
|
|
|
|
|
|
|
|
|
/* configure break and dead-time settings */
|
|
|
|
|
tmr_brkdt_struct.brk_enable = FALSE;
|
|
|
|
|
tmr_brkdt_struct.brk_enable = FALSE;
|
|
|
|
|
tmr_brkdt_struct.auto_output_enable = FALSE;
|
|
|
|
|
tmr_brkdt_struct.brk_polarity = TMR_BRK_INPUT_ACTIVE_LOW;
|
|
|
|
|
tmr_brkdt_struct.fcsoen_state = FALSE;
|
|
|
|
|
tmr_brkdt_struct.fcsodis_state = FALSE;
|
|
|
|
|
tmr_brkdt_struct.wp_level = TMR_WP_OFF;
|
|
|
|
|
tmr_brkdt_struct.deadtime = 0;
|
|
|
|
|
tmr_brkdt_struct.brk_polarity = TMR_BRK_INPUT_ACTIVE_LOW;
|
|
|
|
|
tmr_brkdt_struct.fcsoen_state = FALSE;
|
|
|
|
|
tmr_brkdt_struct.fcsodis_state = FALSE;
|
|
|
|
|
tmr_brkdt_struct.wp_level = TMR_WP_OFF;
|
|
|
|
|
tmr_brkdt_struct.deadtime = 0;
|
|
|
|
|
tmr_brkdt_config(TMR8, &tmr_brkdt_struct);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tmr_output_enable(TMR8, TRUE);
|
|
|
|
|
|
|
|
|
|
tmr_counter_enable(TMR8, TRUE);
|
|
|
|
|
@@ -716,10 +722,10 @@ void wk_tmr8_init(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief init tmr11 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief init tmr11 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_tmr11_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin tmr11_init 0 */
|
|
|
|
|
@@ -735,10 +741,10 @@ void wk_tmr11_init(void)
|
|
|
|
|
/* add user code end tmr11_init 1 */
|
|
|
|
|
|
|
|
|
|
/* configure the CH1 pin */
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_9;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_9;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init(GPIOB, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
@@ -749,13 +755,13 @@ void wk_tmr11_init(void)
|
|
|
|
|
tmr_period_buffer_enable(TMR11, FALSE);
|
|
|
|
|
|
|
|
|
|
/* configure channel 1 output settings */
|
|
|
|
|
tmr_output_struct.oc_mode = TMR_OUTPUT_CONTROL_PWM_MODE_A;
|
|
|
|
|
tmr_output_struct.oc_output_state = TRUE;
|
|
|
|
|
tmr_output_struct.oc_mode = TMR_OUTPUT_CONTROL_PWM_MODE_A;
|
|
|
|
|
tmr_output_struct.oc_output_state = TRUE;
|
|
|
|
|
tmr_output_struct.occ_output_state = FALSE;
|
|
|
|
|
tmr_output_struct.oc_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.occ_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.oc_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.occ_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.oc_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.occ_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.oc_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.occ_idle_state = FALSE;
|
|
|
|
|
tmr_output_channel_config(TMR11, TMR_SELECT_CHANNEL_1, &tmr_output_struct);
|
|
|
|
|
tmr_channel_value_set(TMR11, TMR_SELECT_CHANNEL_1, 0);
|
|
|
|
|
tmr_output_channel_buffer_enable(TMR11, TMR_SELECT_CHANNEL_1, FALSE);
|
|
|
|
|
@@ -770,10 +776,10 @@ void wk_tmr11_init(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief init tmr12 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief init tmr12 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_tmr12_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin tmr12_init 0 */
|
|
|
|
|
@@ -789,18 +795,18 @@ void wk_tmr12_init(void)
|
|
|
|
|
/* add user code end tmr12_init 1 */
|
|
|
|
|
|
|
|
|
|
/* configure the CH1 pin */
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_14;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_14;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init(GPIOB, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* configure the CH2 pin */
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_15;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_15;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init(GPIOB, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
@@ -811,25 +817,25 @@ void wk_tmr12_init(void)
|
|
|
|
|
tmr_period_buffer_enable(TMR12, FALSE);
|
|
|
|
|
|
|
|
|
|
/* configure channel 1 output settings */
|
|
|
|
|
tmr_output_struct.oc_mode = TMR_OUTPUT_CONTROL_OFF;
|
|
|
|
|
tmr_output_struct.oc_output_state = TRUE;
|
|
|
|
|
tmr_output_struct.oc_mode = TMR_OUTPUT_CONTROL_OFF;
|
|
|
|
|
tmr_output_struct.oc_output_state = TRUE;
|
|
|
|
|
tmr_output_struct.occ_output_state = FALSE;
|
|
|
|
|
tmr_output_struct.oc_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.occ_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.oc_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.occ_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.oc_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.occ_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.oc_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.occ_idle_state = FALSE;
|
|
|
|
|
tmr_output_channel_config(TMR12, TMR_SELECT_CHANNEL_1, &tmr_output_struct);
|
|
|
|
|
tmr_channel_value_set(TMR12, TMR_SELECT_CHANNEL_1, 0);
|
|
|
|
|
tmr_output_channel_buffer_enable(TMR12, TMR_SELECT_CHANNEL_1, FALSE);
|
|
|
|
|
|
|
|
|
|
/* configure channel 2 output settings */
|
|
|
|
|
tmr_output_struct.oc_mode = TMR_OUTPUT_CONTROL_OFF;
|
|
|
|
|
tmr_output_struct.oc_output_state = TRUE;
|
|
|
|
|
tmr_output_struct.oc_mode = TMR_OUTPUT_CONTROL_OFF;
|
|
|
|
|
tmr_output_struct.oc_output_state = TRUE;
|
|
|
|
|
tmr_output_struct.occ_output_state = FALSE;
|
|
|
|
|
tmr_output_struct.oc_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.occ_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.oc_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.occ_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.oc_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.occ_polarity = TMR_OUTPUT_ACTIVE_HIGH;
|
|
|
|
|
tmr_output_struct.oc_idle_state = FALSE;
|
|
|
|
|
tmr_output_struct.occ_idle_state = FALSE;
|
|
|
|
|
tmr_output_channel_config(TMR12, TMR_SELECT_CHANNEL_2, &tmr_output_struct);
|
|
|
|
|
tmr_channel_value_set(TMR12, TMR_SELECT_CHANNEL_2, 0);
|
|
|
|
|
tmr_output_channel_buffer_enable(TMR12, TMR_SELECT_CHANNEL_2, FALSE);
|
|
|
|
|
@@ -842,16 +848,16 @@ void wk_tmr12_init(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief init can1 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief init can1 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_can1_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin can1_init 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end can1_init 0 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gpio_init_type gpio_init_struct;
|
|
|
|
|
can_base_type can_base_struct;
|
|
|
|
|
can_baudrate_type can_baudrate_struct;
|
|
|
|
|
@@ -860,57 +866,57 @@ void wk_can1_init(void)
|
|
|
|
|
/* add user code begin can1_init 1 */
|
|
|
|
|
|
|
|
|
|
/* add user code end can1_init 1 */
|
|
|
|
|
|
|
|
|
|
/*gpio-----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
/*gpio-----------------------------------------------------------------------------*/
|
|
|
|
|
gpio_default_para_init(&gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* configure the CAN1 TX pin */
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_12;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_12;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init(GPIOA, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* configure the CAN1 RX pin */
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_INPUT;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_11;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_INPUT;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_11;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init(GPIOA, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/*can_base_init--------------------------------------------------------------------*/
|
|
|
|
|
/*can_base_init--------------------------------------------------------------------*/
|
|
|
|
|
can_default_para_init(&can_base_struct);
|
|
|
|
|
can_base_struct.mode_selection = CAN_MODE_COMMUNICATE;
|
|
|
|
|
can_base_struct.ttc_enable = FALSE;
|
|
|
|
|
can_base_struct.aebo_enable = TRUE;
|
|
|
|
|
can_base_struct.aed_enable = TRUE;
|
|
|
|
|
can_base_struct.prsf_enable = FALSE;
|
|
|
|
|
can_base_struct.mode_selection = CAN_MODE_COMMUNICATE;
|
|
|
|
|
can_base_struct.ttc_enable = FALSE;
|
|
|
|
|
can_base_struct.aebo_enable = TRUE;
|
|
|
|
|
can_base_struct.aed_enable = TRUE;
|
|
|
|
|
can_base_struct.prsf_enable = FALSE;
|
|
|
|
|
can_base_struct.mdrsel_selection = CAN_DISCARDING_FIRST_RECEIVED;
|
|
|
|
|
can_base_struct.mmssr_selection = CAN_SENDING_BY_ID;
|
|
|
|
|
can_base_struct.mmssr_selection = CAN_SENDING_BY_ID;
|
|
|
|
|
|
|
|
|
|
can_base_init(CAN1, &can_base_struct);
|
|
|
|
|
|
|
|
|
|
/*can_baudrate_setting-------------------------------------------------------------*/
|
|
|
|
|
/*set baudrate = pclk/(baudrate_div *(1 + bts1_size + bts2_size))------------------*/
|
|
|
|
|
can_baudrate_struct.baudrate_div = 24; /*value: 1~0xFFF*/
|
|
|
|
|
can_baudrate_struct.rsaw_size = CAN_RSAW_1TQ; /*value: 1~4*/
|
|
|
|
|
can_baudrate_struct.bts1_size = CAN_BTS1_8TQ; /*value: 1~16*/
|
|
|
|
|
can_baudrate_struct.bts2_size = CAN_BTS2_1TQ; /*value: 1~8*/
|
|
|
|
|
/*can_baudrate_setting-------------------------------------------------------------*/
|
|
|
|
|
/*set baudrate = pclk/(baudrate_div *(1 + bts1_size + bts2_size))------------------*/
|
|
|
|
|
can_baudrate_struct.baudrate_div = 24; /*value: 1~0xFFF*/
|
|
|
|
|
can_baudrate_struct.rsaw_size = CAN_RSAW_1TQ; /*value: 1~4*/
|
|
|
|
|
can_baudrate_struct.bts1_size = CAN_BTS1_8TQ; /*value: 1~16*/
|
|
|
|
|
can_baudrate_struct.bts2_size = CAN_BTS2_1TQ; /*value: 1~8*/
|
|
|
|
|
can_baudrate_set(CAN1, &can_baudrate_struct);
|
|
|
|
|
|
|
|
|
|
/*can_filter_0_config--------------------------------------------------------------*/
|
|
|
|
|
can_filter_init_struct.filter_activate_enable = TRUE;
|
|
|
|
|
can_filter_init_struct.filter_number = 0;
|
|
|
|
|
can_filter_init_struct.filter_fifo = CAN_FILTER_FIFO0;
|
|
|
|
|
can_filter_init_struct.filter_bit = CAN_FILTER_16BIT;
|
|
|
|
|
can_filter_init_struct.filter_mode = CAN_FILTER_MODE_ID_MASK;
|
|
|
|
|
can_filter_init_struct.filter_number = 0;
|
|
|
|
|
can_filter_init_struct.filter_fifo = CAN_FILTER_FIFO0;
|
|
|
|
|
can_filter_init_struct.filter_bit = CAN_FILTER_16BIT;
|
|
|
|
|
can_filter_init_struct.filter_mode = CAN_FILTER_MODE_ID_MASK;
|
|
|
|
|
/*Standard identifier + Mask Mode + Data/Remote frame: id/mask 11bit --------------*/
|
|
|
|
|
can_filter_init_struct.filter_id_high = 0x0 << 5;
|
|
|
|
|
can_filter_init_struct.filter_id_low = 0x0 << 5;
|
|
|
|
|
can_filter_init_struct.filter_id_high = 0x0 << 5;
|
|
|
|
|
can_filter_init_struct.filter_id_low = 0x0 << 5;
|
|
|
|
|
can_filter_init_struct.filter_mask_high = 0x0 << 5;
|
|
|
|
|
can_filter_init_struct.filter_mask_low = 0x0 << 5;
|
|
|
|
|
can_filter_init_struct.filter_mask_low = 0x0 << 5;
|
|
|
|
|
|
|
|
|
|
can_filter_init(CAN1, &can_filter_init_struct);
|
|
|
|
|
|
|
|
|
|
@@ -922,8 +928,8 @@ void wk_can1_init(void)
|
|
|
|
|
* --void USBFS_L_CAN1_RX0_IRQHandler(void)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*can1 rx0 interrupt config--------------------------------------------------------*/
|
|
|
|
|
// can_interrupt_enable(CAN1, CAN_RF0MIEN_INT, TRUE);
|
|
|
|
|
/*can1 rx0 interrupt config--------------------------------------------------------*/
|
|
|
|
|
//can_interrupt_enable(CAN1, CAN_RF0MIEN_INT, TRUE);
|
|
|
|
|
|
|
|
|
|
/* add user code begin can1_init 2 */
|
|
|
|
|
can_interrupt_enable(CAN1, CAN_RF0MIEN_INT, TRUE);
|
|
|
|
|
@@ -931,16 +937,16 @@ void wk_can1_init(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief init can2 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
* @brief init can2 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_can2_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin can2_init 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end can2_init 0 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gpio_init_type gpio_init_struct;
|
|
|
|
|
can_base_type can_base_struct;
|
|
|
|
|
can_baudrate_type can_baudrate_struct;
|
|
|
|
|
@@ -949,57 +955,57 @@ void wk_can2_init(void)
|
|
|
|
|
/* add user code begin can2_init 1 */
|
|
|
|
|
|
|
|
|
|
/* add user code end can2_init 1 */
|
|
|
|
|
|
|
|
|
|
/*gpio-----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
/*gpio-----------------------------------------------------------------------------*/
|
|
|
|
|
gpio_default_para_init(&gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* configure the CAN2 TX pin */
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_MODERATE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_13;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_13;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init(GPIOB, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/* configure the CAN2 RX pin */
|
|
|
|
|
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_INPUT;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_12;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_INPUT;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_12;
|
|
|
|
|
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
|
|
|
gpio_init(GPIOB, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
/*can_base_init--------------------------------------------------------------------*/
|
|
|
|
|
/*can_base_init--------------------------------------------------------------------*/
|
|
|
|
|
can_default_para_init(&can_base_struct);
|
|
|
|
|
can_base_struct.mode_selection = CAN_MODE_COMMUNICATE;
|
|
|
|
|
can_base_struct.ttc_enable = FALSE;
|
|
|
|
|
can_base_struct.aebo_enable = TRUE;
|
|
|
|
|
can_base_struct.aed_enable = TRUE;
|
|
|
|
|
can_base_struct.prsf_enable = FALSE;
|
|
|
|
|
can_base_struct.mode_selection = CAN_MODE_COMMUNICATE;
|
|
|
|
|
can_base_struct.ttc_enable = FALSE;
|
|
|
|
|
can_base_struct.aebo_enable = TRUE;
|
|
|
|
|
can_base_struct.aed_enable = TRUE;
|
|
|
|
|
can_base_struct.prsf_enable = FALSE;
|
|
|
|
|
can_base_struct.mdrsel_selection = CAN_DISCARDING_FIRST_RECEIVED;
|
|
|
|
|
can_base_struct.mmssr_selection = CAN_SENDING_BY_ID;
|
|
|
|
|
can_base_struct.mmssr_selection = CAN_SENDING_BY_ID;
|
|
|
|
|
|
|
|
|
|
can_base_init(CAN2, &can_base_struct);
|
|
|
|
|
|
|
|
|
|
/*can_baudrate_setting-------------------------------------------------------------*/
|
|
|
|
|
/*set baudrate = pclk/(baudrate_div *(1 + bts1_size + bts2_size))------------------*/
|
|
|
|
|
can_baudrate_struct.baudrate_div = 24; /*value: 1~0xFFF*/
|
|
|
|
|
can_baudrate_struct.rsaw_size = CAN_RSAW_1TQ; /*value: 1~4*/
|
|
|
|
|
can_baudrate_struct.bts1_size = CAN_BTS1_8TQ; /*value: 1~16*/
|
|
|
|
|
can_baudrate_struct.bts2_size = CAN_BTS2_1TQ; /*value: 1~8*/
|
|
|
|
|
/*can_baudrate_setting-------------------------------------------------------------*/
|
|
|
|
|
/*set baudrate = pclk/(baudrate_div *(1 + bts1_size + bts2_size))------------------*/
|
|
|
|
|
can_baudrate_struct.baudrate_div = 24; /*value: 1~0xFFF*/
|
|
|
|
|
can_baudrate_struct.rsaw_size = CAN_RSAW_1TQ; /*value: 1~4*/
|
|
|
|
|
can_baudrate_struct.bts1_size = CAN_BTS1_8TQ; /*value: 1~16*/
|
|
|
|
|
can_baudrate_struct.bts2_size = CAN_BTS2_1TQ; /*value: 1~8*/
|
|
|
|
|
can_baudrate_set(CAN2, &can_baudrate_struct);
|
|
|
|
|
|
|
|
|
|
/*can_filter_0_config--------------------------------------------------------------*/
|
|
|
|
|
can_filter_init_struct.filter_activate_enable = TRUE;
|
|
|
|
|
can_filter_init_struct.filter_number = 0;
|
|
|
|
|
can_filter_init_struct.filter_fifo = CAN_FILTER_FIFO0;
|
|
|
|
|
can_filter_init_struct.filter_bit = CAN_FILTER_16BIT;
|
|
|
|
|
can_filter_init_struct.filter_mode = CAN_FILTER_MODE_ID_MASK;
|
|
|
|
|
can_filter_init_struct.filter_number = 0;
|
|
|
|
|
can_filter_init_struct.filter_fifo = CAN_FILTER_FIFO0;
|
|
|
|
|
can_filter_init_struct.filter_bit = CAN_FILTER_16BIT;
|
|
|
|
|
can_filter_init_struct.filter_mode = CAN_FILTER_MODE_ID_MASK;
|
|
|
|
|
/*Standard identifier + Mask Mode + Data/Remote frame: id/mask 11bit --------------*/
|
|
|
|
|
can_filter_init_struct.filter_id_high = 0x0 << 5;
|
|
|
|
|
can_filter_init_struct.filter_id_low = 0x0 << 5;
|
|
|
|
|
can_filter_init_struct.filter_id_high = 0x0 << 5;
|
|
|
|
|
can_filter_init_struct.filter_id_low = 0x0 << 5;
|
|
|
|
|
can_filter_init_struct.filter_mask_high = 0x0 << 5;
|
|
|
|
|
can_filter_init_struct.filter_mask_low = 0x0 << 5;
|
|
|
|
|
can_filter_init_struct.filter_mask_low = 0x0 << 5;
|
|
|
|
|
|
|
|
|
|
can_filter_init(CAN2, &can_filter_init_struct);
|
|
|
|
|
|
|
|
|
|
@@ -1011,8 +1017,8 @@ void wk_can2_init(void)
|
|
|
|
|
* --void CAN2_RX0_IRQHandler(void)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/*can2 rx0 interrupt config--------------------------------------------------------*/
|
|
|
|
|
// can_interrupt_enable(CAN2, CAN_RF0MIEN_INT, TRUE);
|
|
|
|
|
/*can2 rx0 interrupt config--------------------------------------------------------*/
|
|
|
|
|
//can_interrupt_enable(CAN2, CAN_RF0MIEN_INT, TRUE);
|
|
|
|
|
|
|
|
|
|
/* add user code begin can2_init 2 */
|
|
|
|
|
can_interrupt_enable(CAN2, CAN_RF0MIEN_INT, TRUE);
|
|
|
|
|
@@ -1020,64 +1026,26 @@ void wk_can2_init(void)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief init adc1 function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_adc1_init(void)
|
|
|
|
|
* @brief init crc function.
|
|
|
|
|
* @param none
|
|
|
|
|
* @retval none
|
|
|
|
|
*/
|
|
|
|
|
void wk_crc_init(void)
|
|
|
|
|
{
|
|
|
|
|
/* add user code begin adc1_init 0 */
|
|
|
|
|
/* add user code begin crc_init 0 */
|
|
|
|
|
|
|
|
|
|
/* add user code end adc1_init 0 */
|
|
|
|
|
/* add user code end crc_init 0 */
|
|
|
|
|
|
|
|
|
|
gpio_init_type gpio_init_struct;
|
|
|
|
|
adc_base_config_type adc_base_struct;
|
|
|
|
|
crc_init_data_set(0xFFFFFFFF);
|
|
|
|
|
crc_poly_size_set(CRC_POLY_SIZE_16B);
|
|
|
|
|
crc_poly_value_set(0x8005);
|
|
|
|
|
crc_reverse_input_data_set(CRC_REVERSE_INPUT_BY_BYTE);
|
|
|
|
|
crc_reverse_output_data_set(CRC_REVERSE_OUTPUT_DATA);
|
|
|
|
|
crc_data_reset();
|
|
|
|
|
|
|
|
|
|
gpio_default_para_init(&gpio_init_struct);
|
|
|
|
|
/* add user code begin crc_init 1 */
|
|
|
|
|
|
|
|
|
|
/* add user code begin adc1_init 1 */
|
|
|
|
|
|
|
|
|
|
/* add user code end adc1_init 1 */
|
|
|
|
|
|
|
|
|
|
/*gpio--------------------------------------------------------------------*/
|
|
|
|
|
/* configure the IN0 pin */
|
|
|
|
|
gpio_init_struct.gpio_mode = GPIO_MODE_ANALOG;
|
|
|
|
|
gpio_init_struct.gpio_pins = GPIO_PINS_0;
|
|
|
|
|
gpio_init(GPIOA, &gpio_init_struct);
|
|
|
|
|
|
|
|
|
|
crm_adc_clock_div_set(CRM_ADC_DIV_6);
|
|
|
|
|
|
|
|
|
|
/*adc_common_settings-------------------------------------------------------------*/
|
|
|
|
|
adc_combine_mode_select(ADC_INDEPENDENT_MODE);
|
|
|
|
|
|
|
|
|
|
/*adc_settings--------------------------------------------------------------------*/
|
|
|
|
|
adc_base_default_para_init(&adc_base_struct);
|
|
|
|
|
adc_base_struct.sequence_mode = FALSE;
|
|
|
|
|
adc_base_struct.repeat_mode = FALSE;
|
|
|
|
|
adc_base_struct.data_align = ADC_RIGHT_ALIGNMENT;
|
|
|
|
|
adc_base_struct.ordinary_channel_length = 1;
|
|
|
|
|
adc_base_config(ADC1, &adc_base_struct);
|
|
|
|
|
|
|
|
|
|
/* adc_ordinary_conversionmode-------------------------------------------- */
|
|
|
|
|
adc_ordinary_channel_set(ADC1, ADC_CHANNEL_0, 1, ADC_SAMPLETIME_1_5);
|
|
|
|
|
|
|
|
|
|
adc_ordinary_conversion_trigger_set(ADC1, ADC12_ORDINARY_TRIG_SOFTWARE, TRUE);
|
|
|
|
|
|
|
|
|
|
adc_ordinary_part_mode_enable(ADC1, FALSE);
|
|
|
|
|
|
|
|
|
|
adc_enable(ADC1, TRUE);
|
|
|
|
|
|
|
|
|
|
/* adc calibration-------------------------------------------------------- */
|
|
|
|
|
adc_calibration_init(ADC1);
|
|
|
|
|
while (adc_calibration_init_status_get(ADC1))
|
|
|
|
|
;
|
|
|
|
|
adc_calibration_start(ADC1);
|
|
|
|
|
while (adc_calibration_status_get(ADC1))
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
/* add user code begin adc1_init 2 */
|
|
|
|
|
|
|
|
|
|
/* add user code end adc1_init 2 */
|
|
|
|
|
/* add user code end crc_init 1 */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* add user code begin 1 */
|
|
|
|
|
|