合泰HT32F52352红外NEC编码

红外遥控协议类型:①NEC编码②RC5③RC6

NEC编码格式:①引导码②地址码③地址反码④控制码⑤控制码反码

图1.NEC编码时序图

合泰HT32F52352红外NEC编码_第1张图片

图2.引导码及数据定义

逻辑1:560us低1680us高 逻辑0:560us低 560us高

一个完整的周期为108ms,当我们一直按住 同一个按键的时候,就会隔一段时间发一个引导码(重复)。

合泰HT32F52352红外NEC编码_第2张图片

图三.Repeat波形图

#include "ht32.h"
#include "usart.h"
#include "Delay.h"
#include "led.h"
#include "key.h"
#include "stdio.h"
#include "lcd.h"
#include "gui.h"
#include "test.h"
#include "Initerface.h"
#include "rtc.h"
#include "time.h"
#include "ht32_board_config.h"

#define BreatheMax 600 //定时器呼吸灯

uint8_t data[7] = {0};

uint16_t count = 0;  //计时

uint8_t puff[4] = {0};

u8 sum = 0;
u32 succeed = 0;
u32 fail = 0;
u32 key_sum = 0;
u32 rx_data = 0;
typedef struct
{
  u32 OverflowCounter;
  u32 StartValue;
  u32 CapturePulse;
  TM_CHP_Enum ChannelPolarity;
  bool DataValid;
  bool DataOverwrite;
} sPulseCaptureStructure;

void Capture_Configuration(void);
void Capture_MainRoutine(void);
void Capture_IRQHandler(void);
void Capture_Process(sPulseCaptureStructure* cap, u16 capture_value, bool isCapBeforeUpdate);

void PWM_OUT_Configuration(void);


sPulseCaptureStructure CaptureCHx;

void Timer_Init(void)
{    
    CKCU_PeripClockConfig_TypeDef CKCUClock= {{0}};
    CKCUClock.Bit.BFTM0 = 1;  //开启中断时钟
    CKCU_PeripClockConfig(CKCUClock, ENABLE);
    
    NVIC_EnableIRQ(BFTM0_IRQn);
    
    BFTM_SetCounter(HT_BFTM0, 0);
    //BFTM_SetCompare(HT_BFTM1, SystemCoreClock);//定时1s产生中断
    BFTM_SetCompare(HT_BFTM0, SystemCoreClock/1000);//定时1ms产生中断 呼吸灯1us中断1000000
    BFTM_IntConfig(HT_BFTM0, ENABLE);//使能中断
    BFTM_EnaCmd(HT_BFTM0, ENABLE);//使能BFTM
}


void BFTM0_IRQHandler(void)
{
        if(BFTM_GetFlagStatus(HT_BFTM0) != RESET )
        {    
        
            count++;            
            if(count == 500) //
            {    
                
                count = 0;
            }
            
            //Capture_MainRoutine();
            BFTM_ClearFlag(HT_BFTM0);//清除中断标志
        }
}

void Capture_MainRoutine(void)
{
    u32 Dval = 0;
  u32 data = 9;

    
  if (CaptureCHx.DataValid)
  {
        Dval = CaptureCHx.CapturePulse / (SystemCoreClock / 1000000ul);
    //printf("Capture: %d %8.2f uS\r\n", CaptureCHx.CapturePulse, ((float)CaptureCHx.CapturePulse / (SystemCoreClock / 1000000ul)));
        
        if(Dval>4200 && Dval<4700)
    {
        data = 3;
    }
    
        if(Dval>300 && Dval<800)
   {
     data = 0;
       rx_data <<= 1;
       rx_data |= 0;
       sum++;
   }

    if(Dval>1400 && Dval<1800)
    {
       data = 1;
       rx_data <<= 1;
       rx_data |= 1;
       sum++;
    }

    if(sum >= 32)
    {
        rx_data >>= 8;
        rx_data &= 0x00FF;
        key_sum++;
        switch (rx_data)
        {
            case 0xA2:succeed++;printf("%d:%d + %d = %d%%  RX:CH-\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0x62:succeed++;printf("%d:%d + %d = %d%%  RX:CH\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0xE2:succeed++;printf("%d:%d + %d = %d%%  RX:CH+\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0x22:succeed++;printf("%d:%d + %d = %d%%  RX:|<<\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0x02:succeed++;printf("%d:%d + %d = %d%%  RX:>>|\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0xC2:succeed++;printf("%d:%d + %d = %d%%  RX:>||\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0xE0:succeed++;printf("%d:%d + %d = %d%%  RX:-\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0xA8:succeed++;printf("%d:%d + %d = %d%%  RX:+\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0x90:succeed++;printf("%d:%d + %d = %d%%  RX:EQ\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0x68:succeed++;printf("%d:%d + %d = %d%%  RX:0\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0x98:succeed++;printf("%d:%d + %d = %d%%  RX:100+\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0xB0:succeed++;printf("%d:%d + %d = %d%%  RX:200+\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0x30:succeed++;printf("%d:%d + %d = %d%%  RX:1\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0x18:succeed++;printf("%d:%d + %d = %d%%  RX:2\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0x7A:succeed++;printf("%d:%d + %d = %d%%  RX:3\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0x10:succeed++;printf("%d:%d + %d = %d%%  RX:4\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0x38:succeed++;printf("%d:%d + %d = %d%%  RX:5\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0x5A:succeed++;printf("%d:%d + %d = %d%%  RX:6\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0x42:succeed++;printf("%d:%d + %d = %d%%  RX:7\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0x4A:succeed++;printf("%d:%d + %d = %d%%  RX:8\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            case 0x52:succeed++;printf("%d:%d + %d = %d%%  RX:9\r\n",key_sum,succeed,fail,(succeed*100)/key_sum);break;
            default:fail++;printf("%d:%d + %d = %d%%  RX:%X Error! Please reset the reboot!\r\n",key_sum,succeed,fail,(succeed*100)/key_sum,rx_data);break;
        }
        rx_data = 0;
        sum = 0;
    }
             
    CaptureCHx.DataValid = FALSE;
  }
}

/*********************************************************************************************************//**
  * @brief  Configures TM to capture waveform.
  * @retval None
  ***********************************************************************************************************/
void Capture_Configuration(void)
{
  { /* Enable peripheral clock                                                                              */
    CKCU_PeripClockConfig_TypeDef CKCUClock = {{ 0 }};
    CKCUClock.Bit.AFIO = 1;
    CKCUClock.Bit.HTCFG_CAP_IPN = 1;
    CKCU_PeripClockConfig(CKCUClock, ENABLE);
  }

  /* Configure AFIO mode as TM function                                                                     */
  AFIO_GPxConfig(HTCFG_CAP_GPIO_ID, HTCFG_CAP_AFIO_PIN, AFIO_FUN_MCTM_GPTM);

  { /* Time base configuration                                                                              */

    /* !!! NOTICE !!!
       Notice that the local variable (structure) did not have an initial value.
       Please confirm that there are no missing members in the parameter settings below in this function.
    */
    TM_TimeBaseInitTypeDef TimeBaseInit;

    TimeBaseInit.Prescaler = 1 - 1;                         // Timer clock = CK_AHB / 1
    TimeBaseInit.CounterReload = 0xFFFF;
    TimeBaseInit.RepetitionCounter = 0;
    TimeBaseInit.CounterMode = TM_CNT_MODE_UP;
    TimeBaseInit.PSCReloadTime = TM_PSC_RLD_IMMEDIATE;
    TM_TimeBaseInit(HTCFG_CAP_PORT, &TimeBaseInit);

    /* Clear Update Event Interrupt flag since the "TM_TimeBaseInit()" writes the UEV1G bit                 */
    TM_ClearFlag(HTCFG_CAP_PORT, TM_FLAG_UEV);
  }

  { /* Channel n capture configuration                                                                      */

    /* !!! NOTICE !!!
       Notice that the local variable (structure) did not have an initial value.
       Please confirm that there are no missing members in the parameter settings below in this function.
    */
    TM_CaptureInitTypeDef CapInit;

    TM_CaptureStructInit(&CapInit);
    CapInit.Channel = HTCFG_CAP_CH;
    CapInit.Polarity = TM_CHP_NONINVERTED;
    CapInit.Selection = TM_CHCCS_DIRECT;
    CapInit.Prescaler = TM_CHPSC_OFF;
    #if (LIBCFG_TM_652XX_V1)
    CapInit.Fsampling = TM_CHFDIV_1;
    CapInit.Event = TM_CHFEV_OFF;
    #else
    CapInit.Filter = 0x0;
    #endif
    TM_CaptureInit(HTCFG_CAP_PORT, &CapInit);
  }

  /* Enable TM Channel Capture and Update Event interrupts                                                  */
  TM_IntConfig(HTCFG_CAP_PORT, HTCFG_CAP_CCR | TM_INT_UEV, ENABLE);
  NVIC_EnableIRQ(HTCFG_CAP_IRQn);

  TM_Cmd(HTCFG_CAP_PORT, ENABLE);
}

/*********************************************************************************************************//**
  * @brief  This function handles GPTM interrupt.
  * @retval None
  ***********************************************************************************************************/
void HTCFG_CAP_IRQHandler(void)
{
  bool update_flag = FALSE;

  /* store and clear all interrupt flags                                                                    */
  u32 status = HTCFG_CAP_PORT->INTSR;
  u32 cnt = HTCFG_CAP_PORT->CNTR;
  #if 0
  if ((status & TM_INT_UEV) != (HTCFG_CAP_PORT->INTSR & TM_INT_UEV))
  {
    status = HTCFG_CAP_PORT->INTSR;
    cnt = HTCFG_CAP_PORT->CNTR;
  }
  #endif
  HTCFG_CAP_PORT->INTSR = ~status;

  if (status & TM_INT_UEV)
  {
    update_flag = TRUE;
    /* The OverflowCounter will stop at max value 0xFFFF                                                    */
    if (CaptureCHx.OverflowCounter != 0xFFFF)
      CaptureCHx.OverflowCounter++;
  }

  if (status & HTCFG_CAP_CCR)
  {
    u32 cap_value = TM_GetCaptureCompare(HTCFG_CAP_PORT, HTCFG_CAP_CH);
    bool isCapBeforeUpdate = (update_flag && (cap_value > cnt))? TRUE : FALSE;
    Capture_Process(&CaptureCHx, cap_value, isCapBeforeUpdate);
    TM_ChPolarityConfig(HTCFG_CAP_PORT, HTCFG_CAP_CH, CaptureCHx.ChannelPolarity);
  }
}

/*********************************************************************************************************//**
 * @brief   Capture Process function.
 * @retval  None
 ************************************************************************************************************/
void Capture_Process(sPulseCaptureStructure* cap, u16 capture_value, bool isCapBeforeUpdate)
{
  if (cap->ChannelPolarity == TM_CHP_NONINVERTED)
  {
    /* Reset OverflowCounter and store capture value when rising edge occurred                              */
    if (isCapBeforeUpdate)
    {
      cap->OverflowCounter = 1;
    }
    else
    {
      cap->OverflowCounter = 0;
    }

    cap->StartValue = capture_value;

    /* Change channel polarity to capture when falling edge occur                                           */
    cap->ChannelPolarity = TM_CHP_INVERTED;
  }
  else
  {
    /* Compute pulse width in PCLK unit when falling edge occurred                                          */
    if (isCapBeforeUpdate)
      cap->OverflowCounter--;

    cap->CapturePulse = (cap->OverflowCounter << 16) - cap->StartValue + capture_value + 1;

    if (cap->DataValid)
      cap->DataOverwrite = TRUE;
    else
      cap->DataValid = TRUE;

    /* Change channel polarity to capture when rising edge occur                                            */
    cap->ChannelPolarity = TM_CHP_NONINVERTED;
  }
}

/*********************************************************************************************************//**
  * @brief   Configures TM to output PWM waveform.
  * @retval  None
  * @details Configuration as frequency 1 Hz and duty 2500 uS (10/4000).
  ***********************************************************************************************************/
void PWM_OUT_Configuration(void)
{
  { /* Enable peripheral clock                                                                              */
    CKCU_PeripClockConfig_TypeDef CKCUClock = {{ 0 }};
    CKCUClock.Bit.AFIO = 1;
    CKCUClock.Bit.HTCFG_PWM_IPN = 1;
    CKCU_PeripClockConfig(CKCUClock, ENABLE);
  }

  /* Configure AFIO mode as TM function                                                                     */
  AFIO_GPxConfig(HTCFG_PWM_GPIO_ID, HTCFG_PWM_AFIO_PIN, HTCFG_PWM_AFIO_FUN);

  { /* Time base configuration                                                                              */

    /* !!! NOTICE !!!
       Notice that the local variable (structure) did not have an initial value.
       Please confirm that there are no missing members in the parameter settings below in this function.
    */
    TM_TimeBaseInitTypeDef TimeBaseInit;

    TimeBaseInit.Prescaler = (SystemCoreClock / 4000) - 1;  // Timer clock = 4 kHz
    TimeBaseInit.CounterReload = 4000 - 1;                  // PWM frequency = 1 Hz
    TimeBaseInit.RepetitionCounter = 0;
    TimeBaseInit.CounterMode = TM_CNT_MODE_UP;
    TimeBaseInit.PSCReloadTime = TM_PSC_RLD_IMMEDIATE;
    TM_TimeBaseInit(HTCFG_PWM_PORT, &TimeBaseInit);

    /* Clear Update Event Interrupt flag since the "TM_TimeBaseInit()" writes the UEV1G bit                 */
    #if 0
    TM_ClearFlag(HTCFG_PWM_PORT, TM_FLAG_UEV);
    #endif
  }

  { /* Channel n output configuration                                                                       */

    /* !!! NOTICE !!!
       Notice that the local variable (structure) did not have an initial value.
       Please confirm that there are no missing members in the parameter settings below in this function.
    */
    TM_OutputInitTypeDef OutInit;

    OutInit.Channel = HTCFG_PWM_CH;
    OutInit.OutputMode = TM_OM_PWM2;
    OutInit.Control = TM_CHCTL_ENABLE;
    OutInit.ControlN = TM_CHCTL_DISABLE;
    OutInit.Polarity = TM_CHP_NONINVERTED;
    OutInit.PolarityN = TM_CHP_NONINVERTED;
    OutInit.IdleState = MCTM_OIS_LOW;
    OutInit.IdleStateN = MCTM_OIS_HIGH;
    OutInit.Compare =  4000 - 10;                           // PWM duty = 10/4000 = 2500 us
    OutInit.AsymmetricCompare = 0;
    TM_OutputInit(HTCFG_PWM_PORT, &OutInit);
  }

  TM_Cmd(HTCFG_PWM_PORT, ENABLE);
}
#ifndef __TIME_H
#define __TIME_H     


void Timer_Init(void);
void Led_chang(void);
void show_time(void);

void Capture_Configuration(void);
void Capture_MainRoutine(void);
void Capture_IRQHandler(void);

void PWM_OUT_Configuration(void);
#endif
#include "ht32.h"
#include "usart.h"
#include "Delay.h"
#include "led.h"
#include "key.h"
#include "stdio.h"
#include "lcd.h"
#include "gui.h"
#include "test.h"
#include "Initerface.h"
#include "rtc.h"
#include "time.h"
#include "ht32_board_config.h"


uint8_t urtrx_data[7];

void delay(u32 nCount)
{
  vu32 i;
  for (i = 0; i < 10000 * nCount; i++){}
}


int main(void)
{
        USART_Configuration();    
        LED_Init();
        Timer_Init();
        RETARGET_Configuration();
        Capture_Configuration();

        PWM_OUT_Configuration();
        Led_on();
        printf("START!\r\n");
        
        while(1)
        {
            Capture_MainRoutine();
        }
}

/*********************************************************************************************************//**
 * @file    GPIO/InputOutput/ht32_board_config.h
 * @version $Rev:: 4728         $
 * @date    $Date:: 2020-04-07#$
 * @brief   The header file of board configuration.
 *************************************************************************************************************
 * @attention
 *
 * Firmware Disclaimer Information
 *
 * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the
 *    code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the
 *    proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and
 *    other intellectual property laws.
 *
 * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the
 *    code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties
 *    other than HOLTEK and the customer.
 *
 * 3. The program technical documentation, including the code, is provided "as is" and for customer reference
 *    only. After delivery by HOLTEK, the customer shall use the program technical documentation, including
 *    the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including
 *    the warranties of merchantability, satisfactory quality and fitness for a particular purpose.
 *
 * 

Copyright (C) Holtek Semiconductor Inc. All rights reserved

************************************************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------------------------------------*/ #ifndef __HT32_BOARD_CONFIG_H #define __HT32_BOARD_CONFIG_H #ifdef __cplusplus extern "C" { #endif /* Settings ------------------------------------------------------------------------------------------------*/ #if defined(USE_HT32F52352_SK) #define HTCFG_OUTPUT_LED0_ID (GPIO_PC) #define HTCFG_OUTPUT_LED1_ID (GPIO_PC) #define HTCFG_OUTPUT_LED2_ID (GPIO_PC) #define HTCFG_INPUT_WAKE_ID (GPIO_PB) #define HTCFG_INPUT_KEY1_ID (GPIO_PD) #define HTCFG_INPUT_KEY2_ID (GPIO_PD) #define HTCFG_OUTPUT_LED0_CLK(CK) (CK.Bit.PC) #define HTCFG_OUTPUT_LED1_CLK(CK) (CK.Bit.PC) #define HTCFG_OUTPUT_LED2_CLK(CK) (CK.Bit.PC) #define HTCFG_INPUT_WAKE_CLK(CK) (CK.Bit.PB) #define HTCFG_INPUT_KEY1_CLK(CK) (CK.Bit.PD) #define HTCFG_INPUT_KEY2_CLK(CK) (CK.Bit.PD) #define HTCFG_LED0 (HT_GPIOC) #define HTCFG_LED1 (HT_GPIOC) #define HTCFG_LED2 (HT_GPIOC) #define HTCFG_WAKE (HT_GPIOB) #define HTCFG_KEY1 (HT_GPIOD) #define HTCFG_KEY2 (HT_GPIOD) #define HTCFG_OUTPUT_LED0_AFIO_PIN (AFIO_PIN_14) #define HTCFG_OUTPUT_LED1_AFIO_PIN (AFIO_PIN_15) #define HTCFG_OUTPUT_LED2_AFIO_PIN (AFIO_PIN_1) #define HTCFG_INPUT_WAKE_AFIO_PIN (AFIO_PIN_12) #define HTCFG_INPUT_KEY1_AFIO_PIN (AFIO_PIN_1) #define HTCFG_INPUT_KEY2_AFIO_PIN (AFIO_PIN_2) #define HTCFG_OUTPUT_LED0_GPIO_PIN (GPIO_PIN_14) #define HTCFG_OUTPUT_LED1_GPIO_PIN (GPIO_PIN_15) #define HTCFG_OUTPUT_LED2_GPIO_PIN (GPIO_PIN_1) #define HTCFG_INPUT_WAKE_GPIO_PIN (GPIO_PIN_12) #define HTCFG_INPUT_KEY1_GPIO_PIN (GPIO_PIN_1) #define HTCFG_INPUT_KEY2_GPIO_PIN (GPIO_PIN_2) #endif /* Settings ------------------------------------------------------------------------------------------------*/ #if defined(USE_HT32F52230_SK) #error "This example code does not apply to the chip you selected." #endif #if defined(USE_HT32F52352_SK) #define HTCFG_SPI_MASTER_SEL_GPIO_ID (HT_GPIOB) #define HTCFG_SPI_MASTER_SEL_CLOCK(CK) (CK.Bit.PB) #define HTCFG_SPI_MASTER_CLOCK(CK) (CK.Bit.SPI0) #define HTCFG_SPI_MASTER (HT_SPI0) #define HTCFG_SPI_MASTER_IRQn (SPI0_IRQn) #define HTCFG_SPI_MASTER_SEL_AFIO_PORT (GPIO_PB) #define HTCFG_SPI_MASTER_SCK_AFIO_PORT (GPIO_PB) #define HTCFG_SPI_MASTER_MOSI_AFIO_PORT (GPIO_PB) #define HTCFG_SPI_MASTER_MISO_AFIO_PORT (GPIO_PB) #define HTCFG_SPI_MASTER_SEL_AFIO_PIN (AFIO_PIN_2) #define HTCFG_SPI_MASTER_SCK_AFIO_PIN (AFIO_PIN_3) #define HTCFG_SPI_MASTER_MOSI_AFIO_PIN (AFIO_PIN_4) #define HTCFG_SPI_MASTER_MISO_AFIO_PIN (AFIO_PIN_5) #define HTCFG_SPI_MASTER_IRQHandler (SPI0_IRQHandler) #define HTCFG_SPI_SLAVE_CLOCK(CK) (CK.Bit.SPI1) #define HTCFG_SPI_SLAVE (HT_SPI1) #define HTCFG_SPI_SLAVE_IRQn (SPI1_IRQn) #define HTCFG_SPI_SLAVE_SEL_AFIO_PORT (GPIO_PA) #define HTCFG_SPI_SLAVE_SCK_AFIO_PORT (GPIO_PC) #define HTCFG_SPI_SLAVE_MOSI_AFIO_PORT (GPIO_PC) #define HTCFG_SPI_SLAVE_MISO_AFIO_PORT (GPIO_PC) #define HTCFG_SPI_SLAVE_SEL_AFIO_PIN (AFIO_PIN_4) #define HTCFG_SPI_SLAVE_SCK_AFIO_PIN (AFIO_PIN_5) #define HTCFG_SPI_SLAVE_MOSI_AFIO_PIN (AFIO_PIN_8) #define HTCFG_SPI_SLAVE_MISO_AFIO_PIN (AFIO_PIN_9) #define HTCFG_SPI_SLAVE_IRQHandler (SPI1_IRQHandler) #endif #if defined(USE_HT32F52352_SK) #define _HTCFG_UART_TX_GPIOX A #define _HTCFG_UART_TX_GPION 4 #define _HTCFG_UART_RX_GPIOX A #define _HTCFG_UART_RX_GPION 5 #define HTCFG_UART_IPN USART1 #define HTCFG_TX_PDMA_CH (PDMA_USART1_TX) #define HTCFG_RX_PDMA_CH (PDMA_USART1_RX) #define HTCFG_PDMA_IRQ (PDMACH2_5_IRQn) #define HTCFG_PDMA_IRQHandler (PDMA_CH2_5_IRQHandler) #define HTCFG_PDMA_CURRENT_TRANSFER_SIZE (HT_PDMA->PDMACH2.CTSR >> 16) #endif #define HTCFG_CAP_GPIO_ID STRCAT2(GPIO_P, _HTCFG_CAP_GPIOX) #define HTCFG_CAP_AFIO_PIN STRCAT2(AFIO_PIN_, _HTCFG_CAP_GPION) #define HTCFG_CAP_PORT STRCAT2(HT_, HTCFG_CAP_IPN) #define HTCFG_CAP_CH STRCAT2(TM_CH_, _HTCFG_CAP_CHN) #define HTCFG_UART_TX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_UART_TX_GPIOX) #define HTCFG_UART_RX_GPIO_ID STRCAT2(GPIO_P, _HTCFG_UART_RX_GPIOX) #define HTCFG_UART_TX_AFIO_PIN STRCAT2(AFIO_PIN_, _HTCFG_UART_TX_GPION) #define HTCFG_UART_RX_AFIO_PIN STRCAT2(AFIO_PIN_, _HTCFG_UART_RX_GPION) #define HTCFG_UART_PORT STRCAT2(HT_, HTCFG_UART_IPN) #define HTCFG_UART_IRQn STRCAT2(HTCFG_UART_IPN, _IRQn) #define HTCFG_UART_IRQHandler STRCAT2(HTCFG_UART_IPN, _IRQHandler) #define HTCFG_UART_RX_GPIO_CLK STRCAT2(P, _HTCFG_UART_RX_GPIOX) #define HTCFG_UART_RX_GPIO_PORT STRCAT2(HT_GPIO, _HTCFG_UART_RX_GPIOX) #define HTCFG_UART_RX_GPIO_PIN STRCAT2(GPIO_PIN_, _HTCFG_UART_RX_GPION) #define _HTCFG_CAP_GPIOX C #define _HTCFG_CAP_GPION 5 #define HTCFG_CAP_IPN GPTM0 #define _HTCFG_CAP_CHN 1 #define HTCFG_CAP_CCR (TM_INT_CH1CC) #define _HTCFG_PWM_GPIOX B #define _HTCFG_PWM_GPION 4 #define HTCFG_PWM_IPN SCTM0 #define _HTCFG_PWM_CHN 0 #if (LIBCFG_GPTM_GIRQ == 1) #define HTCFG_CAP_IRQn STRCAT2(HTCFG_CAP_IPN, _G_IRQn) #define HTCFG_CAP_IRQHandler STRCAT2(HTCFG_CAP_IPN, _G_IRQHandler) #else #define HTCFG_CAP_IRQn STRCAT2(HTCFG_CAP_IPN, _IRQn) #define HTCFG_CAP_IRQHandler STRCAT2(HTCFG_CAP_IPN, _IRQHandler) #endif #define HTCFG_PWM_GPIO_ID STRCAT2(GPIO_P, _HTCFG_PWM_GPIOX) #define HTCFG_PWM_AFIO_PIN STRCAT2(AFIO_PIN_, _HTCFG_PWM_GPION) #define HTCFG_PWM_AFIO_FUN STRCAT2(AFIO_FUN_, HTCFG_PWM_IPN) #define HTCFG_PWM_PORT STRCAT2(HT_, HTCFG_PWM_IPN) #define HTCFG_PWM_CH STRCAT2(TM_CH_, _HTCFG_PWM_CHN) #ifdef __cplusplus } #endif #endif

合泰HT32F52352红外NEC编码_第3张图片

图四.测试结果

合泰HT32F52352红外NEC编码_第4张图片

图五.实物图

你可能感兴趣的:(合泰,c语言,mcu)