PT-66DC\PT606668DC\Inc:13个文件

//               Errors.h


/****************************************************************************
 * File Name: Errors.h
 *
 * Description:
 *					Error defines
 *
 * --------------------------------------------------------------------
 * Revision	Author		Date		Comment
 * --------------------------------------------------------------------
 * 1.0          Junrong         2020/02/02		Original
 *
 *****************************************************************************/
#ifndef __ERRORS_H__
#define __ERRORS_H__
#include "Types.h"

//enum
//{
//    SUCCESS,                
//    UHF_ERROR_INVENTORY_FAIL,   // 0x0001—寻卡失败 
//    UHF_ERROR_FRAMECHECK_FAIL,  // 0x0002—通信帧校验码错误 
//    UHF_ERROR_OVER_TEMPERATURE, // 0x0003—温度过高 
//    UHF_ERROR_OVER_RXPOWER,     // 0x0004—反射功率过大
//    
//    UHF_ERROR_NO_TAG = 0x0011,
//    UHF_ERROR_WRONG_PASSWORD,   // 0x0012
//    UHF_ERROR_READ_FAIL,        // 0x0013
//    UHF_ERROR_WRITE_FAIL,       // 0x0014
//    UHF_ERROR_LCOK_FAIL,        // 0x0015
//    UHF_ERROR_KILL_FAIL,        // 0x0016
//    
//    ERROR_INVALID_FRAME = 0xFFFD,
//    ERROR_TIMEOUT       = 0xFFFE,
//    ERROR_UNKNOW_FAIL   = 0xFFFF,
//};
//typedef UINT16 ENUM_ERROR_CODE;

enum
{
	NO_ERROR,               // 0x00
	ERROR_INVALID_PARAM,    // 0x01
	ERROR_TIMEOUT,          // 0x02
	ERROR_NO_SUPPORTED,     // 0x03
    
    ERROR_NO_TAG = 0x11,    // 0x11
    ERROR_WRONG_PASSWORD,   // 0x12
    ERROR_READ_FAIL,        // 0x13
    ERROR_WRITE_FAIL,       // 0x14
    ERROR_LCOK_FAIL,        // 0x15
    ERROR_KILL_FAIL,        // 0x16
    ERROR_OVER_TEMPERATURE, // 0x17
    UHF_ERROR_OVER_RXPOWER, // 0x18
	ERROR_UNKNOW = 0xFF,
};
typedef BYTE ENUM_ERROR_CODE;
#endif

























//                FreeRTOSConfig.h


/*
    FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
    All rights reserved

    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.

    This file is part of the FreeRTOS distribution.

    FreeRTOS is free software; you can redistribute it and/or modify it under
    the terms of the GNU General Public License (version 2) as published by the
    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.

	***************************************************************************
    >>!   NOTE: The modification to the GPL is included to allow you to     !<<
    >>!   distribute a combined work that includes FreeRTOS without being   !<<
    >>!   obliged to provide the source code for proprietary components     !<<
    >>!   outside of the FreeRTOS kernel.                                   !<<
	***************************************************************************

    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    FOR A PARTICULAR PURPOSE.  Full license text is available on the following
    link: http://www.freertos.org/a00114.html

    ***************************************************************************
     *                                                                       *
     *    FreeRTOS provides completely free yet professionally developed,    *
     *    robust, strictly quality controlled, supported, and cross          *
     *    platform software that is more than just the market leader, it     *
     *    is the industry's de facto standard.                               *
     *                                                                       *
     *    Help yourself get started quickly while simultaneously helping     *
     *    to support the FreeRTOS project by purchasing a FreeRTOS           *
     *    tutorial book, reference manual, or both:                          *
     *    http://www.FreeRTOS.org/Documentation                              *
     *                                                                       *
    ***************************************************************************

    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading
	the FAQ page "My application does not run, what could be wrong?".  Have you
	defined configASSERT()?

	http://www.FreeRTOS.org/support - In return for receiving this top quality
	embedded software for free we request you assist our global community by
	participating in the support forum.

	http://www.FreeRTOS.org/training - Investing in training allows your team to
	be as productive as possible as early as possible.  Now you can receive
	FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
	Ltd, and the world's leading authority on the world's leading RTOS.

    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
    including FreeRTOS+Trace - an indispensable productivity tool, a DOS
    compatible FAT file system, and our tiny thread aware UDP/IP stack.

    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.

    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS
    licenses offer ticketed support, indemnification and commercial middleware.

    http://www.SafeRTOS.com - High Integrity Systems also provide a safety
    engineered and independently SIL3 certified version for use in safety and
    mission critical applications that require provable dependability.

    1 tab == 4 spaces!
*/

#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H

/*-----------------------------------------------------------
 * Application specific definitions.
 *
 * These definitions should be adjusted for your particular hardware and
 * application requirements.
 *
 * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
 * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
 *
 * See http://www.freertos.org/a00110.html.
 *----------------------------------------------------------*/

/* USER CODE BEGIN Includes */   	      
/* Section where include file can be added */
/* USER CODE END Includes */ 

/* Ensure stdint is only used by the compiler, and not the assembler. */
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
    #include <stdint.h>
    extern uint32_t SystemCoreClock;
#endif

#define configUSE_PREEMPTION                     1
#define configSUPPORT_STATIC_ALLOCATION          0
#define configSUPPORT_DYNAMIC_ALLOCATION         1
#define configUSE_IDLE_HOOK                      0
#define configUSE_TICK_HOOK                      0
#define configCPU_CLOCK_HZ                       ( SystemCoreClock )
#define configTICK_RATE_HZ                       ((TickType_t)1000)
#define configMAX_PRIORITIES                     ( 7 )
#define configMINIMAL_STACK_SIZE                 ((uint16_t)64)
#define configTOTAL_HEAP_SIZE                    ((size_t)32768)
#define configMAX_TASK_NAME_LEN                  ( 8 )
#define configUSE_16_BIT_TICKS                   0
#define configUSE_MUTEXES                        1
#define configUSE_COUNTING_SEMAPHORES            1
#define configQUEUE_REGISTRY_SIZE                8
#define configUSE_PORT_OPTIMISED_TASK_SELECTION  1
//#define configCHECK_FOR_STACK_OVERFLOW  2

/* Co-routine definitions. */
#define configUSE_CO_ROUTINES                    0
#define configMAX_CO_ROUTINE_PRIORITIES          ( 2 )

/* Software timer definitions. */
#define configUSE_TIMERS                         0
#define configTIMER_TASK_PRIORITY                ( 2 )
#define configTIMER_QUEUE_LENGTH                 10
#define configTIMER_TASK_STACK_DEPTH             256

/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet            1
#define INCLUDE_uxTaskPriorityGet           1
#define INCLUDE_vTaskDelete                 1
#define INCLUDE_vTaskCleanUpResources       0
#define INCLUDE_vTaskSuspend                1
#define INCLUDE_vTaskDelayUntil             0
#define INCLUDE_vTaskDelay                  1
#define INCLUDE_xTaskGetSchedulerState      1

/* Cortex-M specific definitions. */
#ifdef __NVIC_PRIO_BITS
 /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
 #define configPRIO_BITS         __NVIC_PRIO_BITS
#else
 #define configPRIO_BITS         4
#endif

/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY   15

/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5

/* Interrupt priorities used by the kernel port layer itself.  These are generic
to all Cortex-M ports, and do not rely on any particular library functions. */
#define configKERNEL_INTERRUPT_PRIORITY 		( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 	( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )

/* Normal assert() semantics without relying on the provision of an assert.h
header file. */
/* USER CODE BEGIN 1 */
#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} 
/* USER CODE END 1 */

/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
standard names. */
#define vPortSVCHandler    SVC_Handler
#define xPortPendSVHandler PendSV_Handler

/* IMPORTANT: This define MUST be commented when used with STM32Cube firmware, 
              to prevent overwriting SysTick_Handler defined within STM32Cube HAL */
/* #define xPortSysTickHandler SysTick_Handler */

/* USER CODE BEGIN Defines */   	      
/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */
/* USER CODE END Defines */ 

#endif /* FREERTOS_CONFIG_H */



























//                                   IODefines.h


/****************************************************************************
 * File Name: IODefines.h
 *
 * Description:
 *					IO Defines
 *
 * --------------------------------------------------------------------
 * Revision	Author		Date		Comment
 * --------------------------------------------------------------------
 * 1.0          Junrong         2016/02/28		Original
 *
 *****************************************************************************/
#ifndef __IO_DEFINES_H__
#define __IO_DEFINES_H__ 
#include "stm32f1xx_hal.h"

//#define __DEBUG__


#define MODEL_PT66DC    //MODEL_PT60DC // MODEL_PT68DC   
#define BRAND_PUTY     //BRAND_PUTY // BRAND_ORVED  // BRAND_RU
    
#define DISABLE_BT
    
#define BT_PIN      "1234"
#if defined(MODEL_PT68DC)
    #define MODEL_NO    "PT-68DC"
#elif defined(MODEL_PT60DC)
    #define MODEL_NO    "PT-60DC"
#elif defined(MODEL_PT66DC)
    #define MODEL_NO    "PT-66DC"
#else
    #error ""
#endif

#define PIXEL_MOTOR_STEP    (4) //像素电机步骤
#define PIXEL_VALUE         (8) //像素值
#define mmToPixel(_mm)      ((_mm) * PIXEL_VALUE) //每mm毫米8个像素点
#define PixelToMm(_p)       ((_p) / PIXEL_VALUE)	//每个像素点1/8毫米

#define PixelToPrintSteps(_v) ((_v) * PIXEL_MOTOR_STEP) //每像素电机走四拍
#define mmToPrintSteps(_mm)    ((_mm) * PIXEL_VALUE * PIXEL_MOTOR_STEP)
#define SpeedLevelToValue(_lv) (8 + _lv)


#define PAPER_GAP_DETECTION_MAX_LENGTH  (mmToPixel(300))         // 300 mm 间隙纸检测最大长度
#define SENSOR_TO_HEAT_LENGTH           (mmToPixel(15))          // 15 mm  传感器到加热头长度
#define HEAT_TO_CUTTER_LENGTH           (mmToPixel(21))          // 21 mm  加热头到切刀长度

//#if defined(MODEL_PT68DC)
    #define HEAT_TO_ANTENNA_LENGTH          (mmToPixel(20))          // 14 mm
//#elif defined(MODEL_PT60DC)
//    #define HEAT_TO_ANTENNA_LENGTH          (mmToPixel(14))          // 14 mm
//#else
//    #error ""
//#endif

#define RIBBON_TIGHTEN_LENGTH           (mmToPixel(4))//4*8 =32像素点      

#define GAP_DETECTION_MAX_LENGTH        (1000)  // mm
#define GAP_DETECTION_MIN_LENGTH        (15)    // mm

#define BATTORY_SHUTDOWN_THRESHOLD      (6800)  // mv
#define BATTORY_LEVEL_DEBOUNCE          (100)    // mv

#define PAPER_SENSOR_DEBOUNCE_VALUE       20
#define PAPER_EXIST_AND_GAP_DIFF_VOLTAGE  (200)       // mv
#define PAPER_ADC_THRESHOLD_EMPTY         (2800)      // 2800 ~ 3300 mv
#define PAPER_ADC_THRESHOLD_BLOCK         (2500)      // 2800 ~ 3300 mv
                        
#define PH_OPEN_VOLTAGE_THRESHOLD       (2500)
#define RIBBOM_DET_VOLTAGE_THRESHOLD    (1)         // no ribbon: 230mv, normal:1050mv, Ribbon exhausted: 2900mv,
#define RIBBON_RUNOUT_THRESHOLD         (2000)  // 1200mv

#define RFID_ANTENNA_DISTANCE_MIN   (1)        // mm
#define RFID_ANTENNA_DISTANCE_MAX   (100)       // mm

#define RFID_TX_POWER_MIN   (15)       // dBm
#define RFID_TX_POWER_MAX   (25)       // dBm

#define PTINT_DENSITY_HEAT_TIME_MIN     (200)//(140)   // 200us
#define PTINT_DENSITY_HEAT_TIME_STEP    (10)    // 10us
#define PTINT_SPEED_PULSE_TIME_MIN      (1700)  // 1800us
#define PTINT_SPEED_PULSE_TIME_STEP     (150) //(150)   // 100us

#define mDensityLevelToHeatTime(lv)        (PTINT_DENSITY_HEAT_TIME_MIN + ((lv) * PTINT_DENSITY_HEAT_TIME_STEP)) //200us+(lv*10)us
#define mSpeedLevelToPulseTime(lv)         (PTINT_SPEED_PULSE_TIME_MIN - ((lv) * PTINT_SPEED_PULSE_TIME_STEP))   //1800us-(lv*150)us

extern SPI_HandleTypeDef    hspi1;
#define hspi1FlashHeat	    hspi1
extern SPI_HandleTypeDef    hspi2;
#define SPIHandle_LCD 	    &hspi2
extern SPI_HandleTypeDef    hspi3;
#define SPIHandle_RFID 	    &hspi3


extern ADC_HandleTypeDef    hadc1;
#define hadcBatPower 	    hadc1
extern ADC_HandleTypeDef    hadc2;
#define hadcPHOpen 	        hadc2
extern UART_HandleTypeDef   huart2;
#define huartBT 	        huart2
extern UART_HandleTypeDef   huart1;
#define huartUHF 	        huart1

extern TIM_HandleTypeDef    htim3;
#define htimBUZZER          htim3
extern TIM_HandleTypeDef    htim2;
#define htimMOTOR           htim2
extern TIM_HandleTypeDef    htim4;
#define htimHEAT            htim4
extern TIM_HandleTypeDef    htim6;
#define htimUI              htim6
extern TIM_HandleTypeDef    htim5;
#define htimCMD             htim5
extern TIM_HandleTypeDef    htim7;
#define htimPrinter         htim7

#define GPIO_LCD_RST            GPIOD,GPIO_PIN_8
#define GPIO_LCD_RS             GPIOB,GPIO_PIN_14
#define GPIO_LCD_CS             GPIOB,GPIO_PIN_12

#define GPIO_FLASH_SPI_CS       GPIOA,GPIO_PIN_4    //

#define GPIO_BTN_START          GPIOB,GPIO_PIN_11
#define GPIO_BTN_SETUP          GPIOB,GPIO_PIN_2

#define GPIO_HEAT_LATCH         GPIOC,GPIO_PIN_4
#define GPIO_HEAT_STROBE_1      GPIOE,GPIO_PIN_14
#define GPIO_HEAT_STROBE_2      GPIOE,GPIO_PIN_13
#define GPIO_HEAT_STROBE_3      GPIOE,GPIO_PIN_12
#define GPIO_HEAT_STROBE_4      GPIOE,GPIO_PIN_11
#define GPIO_HEAT_STROBE_5      GPIOE,GPIO_PIN_10
#define GPIO_HEAT_STROBE_6      GPIOE,GPIO_PIN_9
#define GPIO_HEAT_VCC_EN        GPIOD,GPIO_PIN_9

#define GPIO_HR8833_AIN1        GPIOC,GPIO_PIN_6
#define GPIO_HR8833_AIN2        GPIOC,GPIO_PIN_7
#define GPIO_HR8833_BIN1        GPIOC,GPIO_PIN_8
#define GPIO_HR8833_BIN2        GPIOC,GPIO_PIN_9
#define GPIO_HR8833_nSLEEP      GPIOD,GPIO_PIN_11   
#define GPIO_HR8833_nFAULT      GPIOD,GPIO_PIN_12

#define GPIO_POWER_9V_EN        GPIOE,GPIO_PIN_15
#define GPIO_BAT_CHARGE_DET     GPIOD,GPIO_PIN_10
#define GPIO_PAPER_DET_EN       GPIOD,GPIO_PIN_13
//#define GPIO_HEAT_SWITCH_DET    GPIOC,GPIO_PIN_1
#define GPIO_ADAPTER_IN_DET     GPIOB,GPIO_PIN_0

#define GPIO_BUZZER_OUT         GPIOB,GPIO_PIN_1

#define GPIO_USB_ID             GPIOD,GPIO_PIN_15
#define GPIO_USB_VBUS           GPIOD,GPIO_PIN_14

#define GPIO_BT_REST            GPIOD,GPIO_PIN_7
#define GPIO_BT_CONN_STATE      GPIOE,GPIO_PIN_2
#define GPIO_BT_RTS             GPIOA,GPIO_PIN_0


#if defined(MODEL_PT60DC) || defined(MODEL_PT66DC) 
    #define GPIO_HF_SPI_CS          GPIOE,GPIO_PIN_0
    #define GPIO_HF_IRQ             GPIOB,GPIO_PIN_7
    #define GPIO_HF_RST             GPIOB,GPIO_PIN_6
#elif defined(MODEL_PT68DC)
    #define GPIO_UHF_POWER          GPIOA,GPIO_PIN_8
    #define GPIO_UHF_EN             GPIOE,GPIO_PIN_7
#endif


#define _IOWrite(_port, _pin, _val) HAL_GPIO_WritePin(_port, _pin, (GPIO_PinState)_val)
#define _IORead(_port, _pin)        HAL_GPIO_ReadPin(_port, _pin)
#define	_IOToggle(_port, _pin)      HAL_GPIO_TogglePin(_port, _pin)

#define IOWrite(_pin,a) _IOWrite(_pin,(a))
#define IORead(_pin)    _IORead(_pin)
#define IOToggle(_pin)  _IOToggle(_pin)

#define _IOMode(_port,_pin,_mode)  (_pin < GPIO_PIN_8)?((_port)->CRL = (_port)->CRL | (0xF << ((_pin - 1) * 4)) & (_mode << ((_pin - 1) * 4))):((_port)->CRH = (_port)->CRH | (0xF << (((_pin >> 8) - 1) * 4)) & (_mode << (((_pin >> 8) - 1) * 4)))
#define IOMode(_pin,_mode)    _IOMode(_pin, mode)

#endif //__IO_DEFINES_H__





























//                      main.h

/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * This notice applies to any and all portions of this file
  * that are not between comment pairs USER CODE BEGIN and
  * USER CODE END. Other portions of this file, whether 
  * inserted by the user or by software development tools
  * are owned by their respective copyright owners.
  *
  * Copyright (c) 2020 STMicroelectronics International N.V. 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without 
  * modification, are permitted, provided that the following conditions are met:
  *
  * 1. Redistribution of source code must retain the above copyright notice, 
  *    this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright notice,
  *    this list of conditions and the following disclaimer in the documentation
  *    and/or other materials provided with the distribution.
  * 3. Neither the name of STMicroelectronics nor the names of other 
  *    contributors to this software may be used to endorse or promote products 
  *    derived from this software without specific written permission.
  * 4. This software, including modifications and/or derivative works of this 
  *    software, must execute solely and exclusively on microcontroller or
  *    microprocessor devices manufactured by or for STMicroelectronics.
  * 5. Redistribution and use of this software other than as permitted under 
  *    this license is void and will automatically terminate your rights under 
  *    this license. 
  *
  * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 
  * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
  * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
  * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 
  * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H__
#define __MAIN_H__

/* Includes ------------------------------------------------------------------*/

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private define ------------------------------------------------------------*/

#define BT_CONN_STATE_Pin GPIO_PIN_2
#define BT_CONN_STATE_GPIO_Port GPIOE
#define HW_VERSION_1_Pin GPIO_PIN_13
#define HW_VERSION_1_GPIO_Port GPIOC
#define HW_VERSION_2_Pin GPIO_PIN_14
#define HW_VERSION_2_GPIO_Port GPIOC
#define PH_OPEN_DET_ADC_Pin GPIO_PIN_1
#define PH_OPEN_DET_ADC_GPIO_Port GPIOC
#define PAPER_DET_ADC_Pin GPIO_PIN_2
#define PAPER_DET_ADC_GPIO_Port GPIOC
#define PH_TEMP_ADC_Pin GPIO_PIN_3
#define PH_TEMP_ADC_GPIO_Port GPIOC
#define BT_UART2_CTS_Pin GPIO_PIN_0
#define BT_UART2_CTS_GPIO_Port GPIOA
#define BT_UART2_TX_Pin GPIO_PIN_2
#define BT_UART2_TX_GPIO_Port GPIOA
#define BT_UART2_RX_Pin GPIO_PIN_3
#define BT_UART2_RX_GPIO_Port GPIOA
#define FLASH_SPI1_CS_Pin GPIO_PIN_4
#define FLASH_SPI1_CS_GPIO_Port GPIOA
#define PH_LAT_Pin GPIO_PIN_4
#define PH_LAT_GPIO_Port GPIOC
#define BATTERY_ADC_Pin GPIO_PIN_5
#define BATTERY_ADC_GPIO_Port GPIOC
#define ADAPTER_IN_DET_Pin GPIO_PIN_0
#define ADAPTER_IN_DET_GPIO_Port GPIOB
#define BUZZER_OUT_PWM_Pin GPIO_PIN_1
#define BUZZER_OUT_PWM_GPIO_Port GPIOB
#define KEY_SETUP_Pin GPIO_PIN_2
#define KEY_SETUP_GPIO_Port GPIOB
#define KEY_SETUP_EXTI_IRQn EXTI2_IRQn
#define UHF_EN_Pin GPIO_PIN_7
#define UHF_EN_GPIO_Port GPIOE
#define TEST_4_Pin GPIO_PIN_8
#define TEST_4_GPIO_Port GPIOE
#define PH_STB6_Pin GPIO_PIN_9
#define PH_STB6_GPIO_Port GPIOE
#define PH_STB5_Pin GPIO_PIN_10
#define PH_STB5_GPIO_Port GPIOE
#define PH_STB4_Pin GPIO_PIN_11
#define PH_STB4_GPIO_Port GPIOE
#define PH_STB3_Pin GPIO_PIN_12
#define PH_STB3_GPIO_Port GPIOE
#define PH_STB2_Pin GPIO_PIN_13
#define PH_STB2_GPIO_Port GPIOE
#define PH_STB1_Pin GPIO_PIN_14
#define PH_STB1_GPIO_Port GPIOE
#define POWER_EN_Pin GPIO_PIN_15
#define POWER_EN_GPIO_Port GPIOE
#define RESERVE_2_Pin GPIO_PIN_10
#define RESERVE_2_GPIO_Port GPIOB
#define KEY_START_Pin GPIO_PIN_11
#define KEY_START_GPIO_Port GPIOB
#define KEY_START_EXTI_IRQn EXTI15_10_IRQn
#define LCD_SPI2_CS_Pin GPIO_PIN_12
#define LCD_SPI2_CS_GPIO_Port GPIOB
#define LCD_DC_Pin GPIO_PIN_14
#define LCD_DC_GPIO_Port GPIOB
#define LCD_RES_Pin GPIO_PIN_8
#define LCD_RES_GPIO_Port GPIOD
#define PH_VCC_EN_Pin GPIO_PIN_9
#define PH_VCC_EN_GPIO_Port GPIOD
#define POWER_CHARGE_STATE_Pin GPIO_PIN_10
#define POWER_CHARGE_STATE_GPIO_Port GPIOD
#define HR8833_nSLEEP_Pin GPIO_PIN_11
#define HR8833_nSLEEP_GPIO_Port GPIOD
#define HR8833_nFAULT_Pin GPIO_PIN_12
#define HR8833_nFAULT_GPIO_Port GPIOD
#define HR8833_nFAULT_EXTI_IRQn EXTI15_10_IRQn
#define PAPER_DET_EN_Pin GPIO_PIN_13
#define PAPER_DET_EN_GPIO_Port GPIOD
#define USB_VBUS_Pin GPIO_PIN_14
#define USB_VBUS_GPIO_Port GPIOD
#define USB_ID_Pin GPIO_PIN_15
#define USB_ID_GPIO_Port GPIOD
#define HR8833_AIN1_Pin GPIO_PIN_6
#define HR8833_AIN1_GPIO_Port GPIOC
#define HR8833_AIN2_Pin GPIO_PIN_7
#define HR8833_AIN2_GPIO_Port GPIOC
#define HR8833_BIN1_Pin GPIO_PIN_8
#define HR8833_BIN1_GPIO_Port GPIOC
#define HR8833_BIN2_Pin GPIO_PIN_9
#define HR8833_BIN2_GPIO_Port GPIOC
#define UHF_POWER_Pin GPIO_PIN_8
#define UHF_POWER_GPIO_Port GPIOA
#define USB_DM_Pin GPIO_PIN_11
#define USB_DM_GPIO_Port GPIOA
#define USB_DP_Pin GPIO_PIN_12
#define USB_DP_GPIO_Port GPIOA
#define BT_RESET_Pin GPIO_PIN_7
#define BT_RESET_GPIO_Port GPIOD
#define RFID_RESET_Pin GPIO_PIN_6
#define RFID_RESET_GPIO_Port GPIOB
#define RFID_IRQ_Pin GPIO_PIN_7
#define RFID_IRQ_GPIO_Port GPIOB
#define TEST_6_Pin GPIO_PIN_8
#define TEST_6_GPIO_Port GPIOB
#define TEST_5_Pin GPIO_PIN_9
#define TEST_5_GPIO_Port GPIOB
#define RFID_SPI3_CS_Pin GPIO_PIN_0
#define RFID_SPI3_CS_GPIO_Port GPIOE

/* ########################## Assert Selection ############################## */
/**
  * @brief Uncomment the line below to expanse the "assert_param" macro in the 
  *        HAL drivers code
  */
/* #define USE_FULL_ASSERT    1U */

/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

#ifdef __cplusplus
 extern "C" {
#endif
void _Error_Handler(char *, int);

#define Error_Handler() _Error_Handler(__FILE__, __LINE__)
#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H__ */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/





























//                   stm32f1xx_hal_conf.h   


/**
  ******************************************************************************
  * @file    stm32f1xx_hal_conf.h
  * @brief   HAL configuration file.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT(c) 2020 STMicroelectronics</center></h2>
  *
  * Redistribution and use in source and binary forms, with or without modification,
  * are permitted provided that the following conditions are met:
  *   1. Redistributions of source code must retain the above copyright notice,
  *      this list of conditions and the following disclaimer.
  *   2. Redistributions in binary form must reproduce the above copyright notice,
  *      this list of conditions and the following disclaimer in the documentation
  *      and/or other materials provided with the distribution.
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
  *      may be used to endorse or promote products derived from this software
  *      without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  ******************************************************************************
  */ 

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F1xx_HAL_CONF_H
#define __STM32F1xx_HAL_CONF_H

#ifdef __cplusplus
 extern "C" {
#endif

#include "main.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/

/* ########################## Module Selection ############################## */
/**
  * @brief This is the list of modules to be used in the HAL driver 
  */
  
#define HAL_MODULE_ENABLED  
#define HAL_ADC_MODULE_ENABLED
/*#define HAL_CRYP_MODULE_ENABLED   */
/*#define HAL_CAN_MODULE_ENABLED   */
/*#define HAL_CEC_MODULE_ENABLED   */
/*#define HAL_CORTEX_MODULE_ENABLED   */
/*#define HAL_CRC_MODULE_ENABLED   */
/*#define HAL_DAC_MODULE_ENABLED   */
#define HAL_DMA_MODULE_ENABLED
/*#define HAL_ETH_MODULE_ENABLED   */
/*#define HAL_FLASH_MODULE_ENABLED   */
#define HAL_GPIO_MODULE_ENABLED
/*#define HAL_I2C_MODULE_ENABLED   */
/*#define HAL_I2S_MODULE_ENABLED   */
/*#define HAL_IRDA_MODULE_ENABLED   */
/*#define HAL_IWDG_MODULE_ENABLED   */
/*#define HAL_NOR_MODULE_ENABLED   */
/*#define HAL_NAND_MODULE_ENABLED   */
/*#define HAL_PCCARD_MODULE_ENABLED   */
#define HAL_PCD_MODULE_ENABLED
/*#define HAL_HCD_MODULE_ENABLED   */
/*#define HAL_PWR_MODULE_ENABLED   */
/*#define HAL_RCC_MODULE_ENABLED   */
/*#define HAL_RTC_MODULE_ENABLED   */
/*#define HAL_SD_MODULE_ENABLED   */
/*#define HAL_MMC_MODULE_ENABLED   */
/*#define HAL_SDRAM_MODULE_ENABLED   */
/*#define HAL_SMARTCARD_MODULE_ENABLED   */
#define HAL_SPI_MODULE_ENABLED
/*#define HAL_SRAM_MODULE_ENABLED   */
#define HAL_TIM_MODULE_ENABLED
#define HAL_UART_MODULE_ENABLED
/*#define HAL_USART_MODULE_ENABLED   */
/*#define HAL_WWDG_MODULE_ENABLED   */
/*#define HAL_EXTI_MODULE_ENABLED   */

#define HAL_CORTEX_MODULE_ENABLED
#define HAL_DMA_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED
#define HAL_GPIO_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED

/* ########################## Oscillator Values adaptation ####################*/
/**
  * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
  *        This value is used by the RCC HAL module to compute the system frequency
  *        (when HSE is used as system clock source, directly or through the PLL).  
  */
#if !defined  (HSE_VALUE) 
  #define HSE_VALUE    ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */

#if !defined  (HSE_STARTUP_TIMEOUT)
  #define HSE_STARTUP_TIMEOUT    ((uint32_t)100)   /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */

/**
  * @brief Internal High Speed oscillator (HSI) value.
  *        This value is used by the RCC HAL module to compute the system frequency
  *        (when HSI is used as system clock source, directly or through the PLL). 
  */
#if !defined  (HSI_VALUE)
  #define HSI_VALUE    ((uint32_t)8000000) /*!< Value of the Internal oscillator in Hz*/
#endif /* HSI_VALUE */

/**
  * @brief Internal Low Speed oscillator (LSI) value.
  */
#if !defined  (LSI_VALUE) 
 #define LSI_VALUE               40000U    /*!< LSI Typical Value in Hz */
#endif /* LSI_VALUE */                     /*!< Value of the Internal Low Speed oscillator in Hz
                                                The real value may vary depending on the variations
                                                in voltage and temperature. */

/**
  * @brief External Low Speed oscillator (LSE) value.
  *        This value is used by the UART, RTC HAL module to compute the system frequency
  */
#if !defined  (LSE_VALUE)
  #define LSE_VALUE    ((uint32_t)32768) /*!< Value of the External oscillator in Hz*/
#endif /* LSE_VALUE */

#if !defined  (LSE_STARTUP_TIMEOUT)
  #define LSE_STARTUP_TIMEOUT    ((uint32_t)5000)   /*!< Time out for LSE start up, in ms */
#endif /* LSE_STARTUP_TIMEOUT */

/* Tip: To avoid modifying this file each time you need to use different HSE,
   ===  you can define the HSE value in your toolchain compiler preprocessor. */

/* ########################### System Configuration ######################### */
/**
  * @brief This is the HAL system configuration section
  */     
#define  VDD_VALUE                    ((uint32_t)3300) /*!< Value of VDD in mv */           
#define  TICK_INT_PRIORITY            ((uint32_t)0)    /*!< tick interrupt priority (lowest by default)  */            
#define  USE_RTOS                     0
#define  PREFETCH_ENABLE              1

/* ########################## Assert Selection ############################## */
/**
  * @brief Uncomment the line below to expanse the "assert_param" macro in the 
  *        HAL drivers code
  */
/* #define USE_FULL_ASSERT    1U */

/* ################## Ethernet peripheral configuration ##################### */

/* Section 1 : Ethernet peripheral configuration */

/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
#define MAC_ADDR0   2
#define MAC_ADDR1   0
#define MAC_ADDR2   0
#define MAC_ADDR3   0
#define MAC_ADDR4   0
#define MAC_ADDR5   0

/* Definition of the Ethernet driver buffers size and count */   
#define ETH_RX_BUF_SIZE                ETH_MAX_PACKET_SIZE /* buffer size for receive               */
#define ETH_TX_BUF_SIZE                ETH_MAX_PACKET_SIZE /* buffer size for transmit              */
#define ETH_RXBUFNB                    ((uint32_t)8)       /* 4 Rx buffers of size ETH_RX_BUF_SIZE  */
#define ETH_TXBUFNB                    ((uint32_t)4)       /* 4 Tx buffers of size ETH_TX_BUF_SIZE  */

/* Section 2: PHY configuration section */

/* DP83848_PHY_ADDRESS Address*/ 
#define DP83848_PHY_ADDRESS           0x01U
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ 
#define PHY_RESET_DELAY                 ((uint32_t)0x000000FF)
/* PHY Configuration delay */
#define PHY_CONFIG_DELAY                ((uint32_t)0x00000FFF)

#define PHY_READ_TO                     ((uint32_t)0x0000FFFF)
#define PHY_WRITE_TO                    ((uint32_t)0x0000FFFF)

/* Section 3: Common PHY Registers */

#define PHY_BCR                         ((uint16_t)0x00)    /*!< Transceiver Basic Control Register   */
#define PHY_BSR                         ((uint16_t)0x01)    /*!< Transceiver Basic Status Register    */
 
#define PHY_RESET                       ((uint16_t)0x8000)  /*!< PHY Reset */
#define PHY_LOOPBACK                    ((uint16_t)0x4000)  /*!< Select loop-back mode */
#define PHY_FULLDUPLEX_100M             ((uint16_t)0x2100)  /*!< Set the full-duplex mode at 100 Mb/s */
#define PHY_HALFDUPLEX_100M             ((uint16_t)0x2000)  /*!< Set the half-duplex mode at 100 Mb/s */
#define PHY_FULLDUPLEX_10M              ((uint16_t)0x0100)  /*!< Set the full-duplex mode at 10 Mb/s  */
#define PHY_HALFDUPLEX_10M              ((uint16_t)0x0000)  /*!< Set the half-duplex mode at 10 Mb/s  */
#define PHY_AUTONEGOTIATION             ((uint16_t)0x1000)  /*!< Enable auto-negotiation function     */
#define PHY_RESTART_AUTONEGOTIATION     ((uint16_t)0x0200)  /*!< Restart auto-negotiation function    */
#define PHY_POWERDOWN                   ((uint16_t)0x0800)  /*!< Select the power down mode           */
#define PHY_ISOLATE                     ((uint16_t)0x0400)  /*!< Isolate PHY from MII                 */

#define PHY_AUTONEGO_COMPLETE           ((uint16_t)0x0020)  /*!< Auto-Negotiation process completed   */
#define PHY_LINKED_STATUS               ((uint16_t)0x0004)  /*!< Valid link established               */
#define PHY_JABBER_DETECTION            ((uint16_t)0x0002)  /*!< Jabber condition detected            */
  
/* Section 4: Extended PHY Registers */
#define PHY_SR                          ((uint16_t)0x10U)    /*!< PHY status register Offset                      */

#define PHY_SPEED_STATUS                ((uint16_t)0x0002U)  /*!< PHY Speed mask                                  */
#define PHY_DUPLEX_STATUS               ((uint16_t)0x0004U)  /*!< PHY Duplex mask                                 */

/* Includes ------------------------------------------------------------------*/
/**
  * @brief Include module's header file 
  */

#ifdef HAL_RCC_MODULE_ENABLED
 #include "stm32f1xx_hal_rcc.h"
#endif /* HAL_RCC_MODULE_ENABLED */

#ifdef HAL_EXTI_MODULE_ENABLED
 #include "stm32f1xx_hal_exti.h"
#endif /* HAL_EXTI_MODULE_ENABLED */

#ifdef HAL_GPIO_MODULE_ENABLED
 #include "stm32f1xx_hal_gpio.h"
#endif /* HAL_GPIO_MODULE_ENABLED */
   
#ifdef HAL_DMA_MODULE_ENABLED
  #include "stm32f1xx_hal_dma.h"
#endif /* HAL_DMA_MODULE_ENABLED */
   
#ifdef HAL_ETH_MODULE_ENABLED
  #include "stm32f1xx_hal_eth.h"
#endif /* HAL_ETH_MODULE_ENABLED */  
   
#ifdef HAL_CAN_MODULE_ENABLED
 #include "stm32f1xx_hal_can.h"
#endif /* HAL_CAN_MODULE_ENABLED */

#ifdef HAL_CEC_MODULE_ENABLED
 #include "stm32f1xx_hal_cec.h"
#endif /* HAL_CEC_MODULE_ENABLED */

#ifdef HAL_CORTEX_MODULE_ENABLED
 #include "stm32f1xx_hal_cortex.h"
#endif /* HAL_CORTEX_MODULE_ENABLED */

#ifdef HAL_ADC_MODULE_ENABLED
 #include "stm32f1xx_hal_adc.h"
#endif /* HAL_ADC_MODULE_ENABLED */

#ifdef HAL_CRC_MODULE_ENABLED
 #include "stm32f1xx_hal_crc.h"
#endif /* HAL_CRC_MODULE_ENABLED */

#ifdef HAL_DAC_MODULE_ENABLED
 #include "stm32f1xx_hal_dac.h"
#endif /* HAL_DAC_MODULE_ENABLED */

#ifdef HAL_FLASH_MODULE_ENABLED
 #include "stm32f1xx_hal_flash.h"
#endif /* HAL_FLASH_MODULE_ENABLED */

#ifdef HAL_SRAM_MODULE_ENABLED
 #include "stm32f1xx_hal_sram.h"
#endif /* HAL_SRAM_MODULE_ENABLED */

#ifdef HAL_NOR_MODULE_ENABLED
 #include "stm32f1xx_hal_nor.h"
#endif /* HAL_NOR_MODULE_ENABLED */

#ifdef HAL_I2C_MODULE_ENABLED
 #include "stm32f1xx_hal_i2c.h"
#endif /* HAL_I2C_MODULE_ENABLED */

#ifdef HAL_I2S_MODULE_ENABLED
 #include "stm32f1xx_hal_i2s.h"
#endif /* HAL_I2S_MODULE_ENABLED */

#ifdef HAL_IWDG_MODULE_ENABLED
 #include "stm32f1xx_hal_iwdg.h"
#endif /* HAL_IWDG_MODULE_ENABLED */

#ifdef HAL_PWR_MODULE_ENABLED
 #include "stm32f1xx_hal_pwr.h"
#endif /* HAL_PWR_MODULE_ENABLED */

#ifdef HAL_RTC_MODULE_ENABLED
 #include "stm32f1xx_hal_rtc.h"
#endif /* HAL_RTC_MODULE_ENABLED */

#ifdef HAL_PCCARD_MODULE_ENABLED
 #include "stm32f1xx_hal_pccard.h"
#endif /* HAL_PCCARD_MODULE_ENABLED */ 

#ifdef HAL_SD_MODULE_ENABLED
 #include "stm32f1xx_hal_sd.h"
#endif /* HAL_SD_MODULE_ENABLED */  

#ifdef HAL_MMC_MODULE_ENABLED
 #include "stm32f1xx_hal_mmc.h"
#endif /* HAL_MMC_MODULE_ENABLED */

#ifdef HAL_NAND_MODULE_ENABLED
 #include "stm32f1xx_hal_nand.h"
#endif /* HAL_NAND_MODULE_ENABLED */     

#ifdef HAL_SPI_MODULE_ENABLED
 #include "stm32f1xx_hal_spi.h"
#endif /* HAL_SPI_MODULE_ENABLED */

#ifdef HAL_TIM_MODULE_ENABLED
 #include "stm32f1xx_hal_tim.h"
#endif /* HAL_TIM_MODULE_ENABLED */

#ifdef HAL_UART_MODULE_ENABLED
 #include "stm32f1xx_hal_uart.h"
#endif /* HAL_UART_MODULE_ENABLED */

#ifdef HAL_USART_MODULE_ENABLED
 #include "stm32f1xx_hal_usart.h"
#endif /* HAL_USART_MODULE_ENABLED */

#ifdef HAL_IRDA_MODULE_ENABLED
 #include "stm32f1xx_hal_irda.h"
#endif /* HAL_IRDA_MODULE_ENABLED */

#ifdef HAL_SMARTCARD_MODULE_ENABLED
 #include "stm32f1xx_hal_smartcard.h"
#endif /* HAL_SMARTCARD_MODULE_ENABLED */

#ifdef HAL_WWDG_MODULE_ENABLED
 #include "stm32f1xx_hal_wwdg.h"
#endif /* HAL_WWDG_MODULE_ENABLED */

#ifdef HAL_PCD_MODULE_ENABLED
 #include "stm32f1xx_hal_pcd.h"
#endif /* HAL_PCD_MODULE_ENABLED */

#ifdef HAL_HCD_MODULE_ENABLED
 #include "stm32f1xx_hal_hcd.h"
#endif /* HAL_HCD_MODULE_ENABLED */   
   

/* Exported macro ------------------------------------------------------------*/
#ifdef  USE_FULL_ASSERT
/**
  * @brief  The assert_param macro is used for function's parameters check.
  * @param  expr: If expr is false, it calls assert_failed function
  *         which reports the name of the source file and the source
  *         line number of the call that failed. 
  *         If expr is true, it returns no value.
  * @retval None
  */
  #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
  void assert_failed(uint8_t* file, uint32_t line);
#else
  #define assert_param(expr) ((void)0U)
#endif /* USE_FULL_ASSERT */

#ifdef __cplusplus
}
#endif

#endif /* __STM32F1xx_HAL_CONF_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/





























//                                     stm32f1xx_it.h


/**
  ******************************************************************************
  * @file    stm32f1xx_it.h
  * @brief   This file contains the headers of the interrupt handlers.
  ******************************************************************************
  *
  * COPYRIGHT(c) 2020 STMicroelectronics
  *
  * Redistribution and use in source and binary forms, with or without modification,
  * are permitted provided that the following conditions are met:
  *   1. Redistributions of source code must retain the above copyright notice,
  *      this list of conditions and the following disclaimer.
  *   2. Redistributions in binary form must reproduce the above copyright notice,
  *      this list of conditions and the following disclaimer in the documentation
  *      and/or other materials provided with the distribution.
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
  *      may be used to endorse or promote products derived from this software
  *      without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F1xx_IT_H
#define __STM32F1xx_IT_H

#ifdef __cplusplus
 extern "C" {
#endif 

/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal.h"
#include "main.h"
#include "Types.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */

void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void DebugMon_Handler(void);
void SysTick_Handler(void);
void EXTI2_IRQHandler(void);
void DMA1_Channel1_IRQHandler(void);
void DMA1_Channel6_IRQHandler(void);
void USB_LP_CAN1_RX0_IRQHandler(void);
void TIM1_UP_IRQHandler(void);
void USART2_IRQHandler(void);
void EXTI15_10_IRQHandler(void);

void ButtonISR(unsigned char index); // 0: start, 1: setup
void MotorErrtISR(void);
#ifdef __cplusplus
}
#endif

#endif /* __STM32F1xx_IT_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/





























//                      Structures.h


/****************************************************************************
 * File Name: Structures.h
 *
 * Description:
 *					Structures
 *
 * --------------------------------------------------------------------
 * Revision	Author		Date		Comment
 * --------------------------------------------------------------------
 * 1.0          Junrong         2018/02/29		Original
 *
 *****************************************************************************/
#ifndef __STRUCTURES_H__
#define __STRUCTURES_H__
#include <stdint.h>
#include "Types.h"
#include "IODefines.h"

typedef struct
{
    char Version[32];
}ST_BL_INFO;
typedef struct
{
    UINT32      UpgradeFlag;            // 0x00000000: Upgrade Enable, 0x00000001 ~ 0xFFFFFFFF:Normal
    UINT32      ActiveBankNo;           // 0x00000000:Bank0, 0x00000001:Bank1, 0x00000002 ~ 0xFFFFFFFF:NA
    BYTE Version[4];
    char BuildTime[20];
    char Builder[16];
    char Memo[16];
}ST_FW_INFO;

extern const ST_FW_INFO FW_INFO;
extern const ST_BL_INFO *pBL_INFO;


enum
{
	PRINT_DEPTH_1,
	PRINT_DEPTH_2,
	PRINT_DEPTH_3,
	PRINT_DEPTH_4,
	PRINT_DEPTH_5,
	PRINT_DEPTH_6,
	PRINT_DEPTH_7,
	PRINT_DEPTH_8,
	PRINT_DEPTH_9,
	PRINT_DEPTH_10,
	PRINT_DEPTH_11,
	PRINT_DEPTH_12,
	PRINT_DEPTH_13,
	PRINT_DEPTH_14,
	PRINT_DEPTH_15,
	ENUM_PRINT_DEPTH_COUNT
};
typedef BYTE ENUM_PRINT_DEPTH;

enum
{
	PRINT_SPEED_1,
	PRINT_SPEED_2,
	PRINT_SPEED_3,
	PRINT_SPEED_4,
	PRINT_SPEED_5,
	ENUM_PRINT_SPEED_COUNT
};
typedef BYTE ENUM_PRINT_SPEED;

//enum
//{
//	PRINT_DISTANCE_0,
//	PRINT_DISTANCE_3,
//	PRINT_DISTANCE_6,
//	PRINT_DISTANCE_9,
//	PRINT_DISTANCE_12,
//	PRINT_DISTANCE_15,
//	PRINT_DISTANCE_18,
//	PRINT_DISTANCE_21,
//	PRINT_DISTANCE_24,
//	PRINT_DISTANCE_27,
//	PRINT_DISTANCE_30,
//	PRINT_DISTANCE_COUNT
//};
//typedef BYTE ENUM_PRINT_DIST;
enum
{
	LANGUAGE_CHINESE,
	LANGUAGE_ENGLISH,	
    LANGUAGE_ITALIANO,
    LANGUAGE_RU,
	ENUM_LANGUAGE_COUNT
};
typedef BYTE ENUM_LANGUAGE;

enum
{
	SHUT_MODE_NEVER,
	SHUT_MODE_5M,
	SHUT_MODE_10M,
	SHUT_MODE_20M,
	SHUT_MODE_30M,
	ENUM_SHUT_MODE_COUNT
};
typedef BYTE ENUM_SHUT_MODE;
enum
{
    TEXT_CODE_EX_BARCODE = 0x0001,
    TEXT_CODE_EX_QRCODE = 0x0002,
    TEXT_CODE_EX_FULL_SPACE = 0xA1A1,
};
typedef UINT16 TEXT_CODE;

enum
{
	ORIENTATION_HORIZONTAL,
    ORIENTATION_VERTICAL,
	ENUM_ORIENTATION_COUNT,
};
typedef BYTE ENUM_ORIENTATION;

enum
{
    LENGTH_AUTO,
    LENGTH_FIX,
	ENUM_LENGTH_MODE_COUNT,
};
typedef BYTE ENUM_LENGTH_MODE;

enum
{
    BARCODE_CODE39,
    BARCODE_CODE128,
    BARCODE_EAN8,
    BARCODE_EAN13,
    BARCODE_UPC_A,
    BARCODE_UPC_E,
    BARCODE_CODABAR,
    BARCODE_QRCODE,
    ENUM_BARCODE_COUNT,
};
typedef BYTE ENUM_BARCODE_TYPE;

enum
{
    BARCODE_WIDTH_BIG,
    BARCODE_WIDTH_SMALL,
    ENUM_BARCODE_WIDTH_COUNT,
};
typedef BYTE ENUM_BARCODE_WIDTH;

typedef struct
{
    ENUM_BARCODE_TYPE   CodeType;
    ENUM_BARCODE_WIDTH  BarcodeWidth;
    BOOL                TextEn;
    BOOL                ChecksumEn;
    BYTE                CorrectLevel;
}ST_BARCODE_CONFIG;

typedef struct
{
//    ST_BARCODE_CONFIG   Config;
    char               *pData;
    BYTE                Length;
    BYTE                Index;
    char                Checksum;
}ST_BARCODE_BUFFER;

enum
{
    PRINT_MODE_NORMAL,
    PRINT_MODE_DRIVER,
    ENUM_PRINT_MODE_COUNT,
};
typedef BYTE ENUM_PRINT_MODE;
enum
{
    PAPER_TYPE_NORMAL,
    PAPER_TYPE_BLACK,
    PAPER_TYPE_GAP,
    PAPER_TYPE_HOLE,
#if defined(MODEL_PT68DC) || defined(MODEL_PT60DC)
    PAPER_TYPE_RFID,
#endif
    ENUM_PAPER_TYPE_COUNT
};
typedef BYTE ENUM_PAPER_TYPE;
typedef struct
{
    BYTE            Depth; //
    BYTE            Speed; //
    ENUM_PAPER_TYPE PaperType;
    ENUM_PRINT_MODE PrintMode;
    BYTE            Distance;   // RFID Antenna Distance (unit: mm)
    BYTE            TxPower;    // // 15 - 25 dBm
    SIZE            LabelSize;
}ST_PRINT_CONFIG;

#if defined(MODEL_PT68DC)
typedef struct
{
    BYTE Bank;
    BYTE Addr;
    BYTE Count; // word
    BYTE Data[32];
}ST_RFID_WRITE_DATA;
#elif defined(MODEL_PT60DC)   
typedef struct
{
    BYTE Block;
    BYTE Data[16];
}ST_RFID_WRITE_DATA;
#endif

typedef struct
{
#if defined(MODEL_PT68DC)
    ST_RFID_WRITE_DATA Slot[16];
#elif defined(MODEL_PT60DC)    
    ST_RFID_WRITE_DATA Slot[24];
#endif
    BYTE SlotCount;
    BYTE LabelIndex;
}ST_RFID_PRINTING_WRITE_STATUS;
#define VALID_CHECK_VALUE        0x55AA5AA5
#define DEVICE_DB_TABLE_VERSION 3
typedef struct
{
    UINT32              ValidCheck1;
    UINT32              TableVersion;
    ST_PRINT_CONFIG     PrintConfig;
    ENUM_LANGUAGE       Language;
    ENUM_SHUT_MODE      ShutMode;
    UINT16              GapVoltageThreshold;
    UINT32              ValidCheck2;
}ST_DEVICE_DATABASE;
extern ST_DEVICE_DATABASE DeviceDB;

enum
{
    BATTERY_LEVEL_0,    // Low
    BATTERY_LEVEL_1,    //
    BATTERY_LEVEL_2,    // Middle
    BATTERY_LEVEL_3,    // 
    BATTERY_LEVEL_4,    // Full
    ENUM_BATTERY_LEVEL_COUNT
};
typedef BYTE ENUM_BATTERY_LEVEL;
typedef struct
{
    BOOL BTConn:1;
    BOOL USBConn:1;
    BOOL PHOpen:1;
    BOOL NoPaper:1;
    BOOL Charging:1;
    BOOL DcConn:1;
    BOOL BatteryLow:1;
    BOOL NoDetectGap:1;
    BOOL RibbonNoDetect:1;
    BOOL RibbonRunout:1;
    BOOL PauseFlag:1;
    BOOL AbortFlag:1;
    BOOL CalibratingFlag:1;
    BOOL CalibrationFailed:1;
    UINT16 BatVoltage;
    ENUM_BATTERY_LEVEL BatLevel;
    UINT16 PaperSensorVoltage;
    UINT16 PHTempVoltage;
    UINT16 RibbonVoltage;
    //float  SysTemperature;
}ST_SYSTEM_STATUS;
extern ST_SYSTEM_STATUS SystemStatus;

#endif



























//                                            Types.h


/****************************************************************************
 * File Name: Types.h
 *
 * Description:
 *					Type defines
 *
 * --------------------------------------------------------------------
 * Revision	Author		Date		Comment
 * --------------------------------------------------------------------
 * 1.0          Junrong         2016/02/29		Original
 *
 *****************************************************************************/
#ifndef __TYPES_H__
#define __TYPES_H__
#include <stdint.h>
typedef uint8_t 	UINT8, BYTE;
typedef uint16_t 	UINT16;
typedef uint32_t 	UINT32;
typedef int8_t 		INT8;
typedef int16_t 	INT16;
typedef int32_t 	INT32;

typedef BYTE BOOL;

typedef void *HANDLE;

typedef struct
{
    INT16 X;
    INT16 Y;
}POINT;
typedef struct
{
    UINT16 Width;
    UINT16 Height;
}SIZE;
#define TRUE 	1
#define FALSE	0

#define MIN(a, b)  (((a) < (b)) ? (a) : (b))
#define MAX(a, b)  (((a) > (b)) ? (a) : (b))
#define ABS(a)     (((a) > 0  ) ? (a) : (-a))

#define __PACKED__ __attribute__((__packed__))
#endif //__TYPES_H__


























//                    usb_device.h


/**
  ******************************************************************************
  * @file           : usb_device.h
  * @version        : v2.0_Cube
  * @brief          : Header for usb_device.c file.
  ******************************************************************************
  * This notice applies to any and all portions of this file
  * that are not between comment pairs USER CODE BEGIN and
  * USER CODE END. Other portions of this file, whether 
  * inserted by the user or by software development tools
  * are owned by their respective copyright owners.
  *
  * Copyright (c) 2020 STMicroelectronics International N.V. 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without 
  * modification, are permitted, provided that the following conditions are met:
  *
  * 1. Redistribution of source code must retain the above copyright notice, 
  *    this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright notice,
  *    this list of conditions and the following disclaimer in the documentation
  *    and/or other materials provided with the distribution.
  * 3. Neither the name of STMicroelectronics nor the names of other 
  *    contributors to this software may be used to endorse or promote products 
  *    derived from this software without specific written permission.
  * 4. This software, including modifications and/or derivative works of this 
  *    software, must execute solely and exclusively on microcontroller or
  *    microprocessor devices manufactured by or for STMicroelectronics.
  * 5. Redistribution and use of this software other than as permitted under 
  *    this license is void and will automatically terminate your rights under 
  *    this license. 
  *
  * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 
  * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
  * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
  * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 
  * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USB_DEVICE__H__
#define __USB_DEVICE__H__

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx.h"
#include "stm32f1xx_hal.h"
#include "usbd_def.h"

/* USER CODE BEGIN INCLUDE */

/* USER CODE END INCLUDE */

/** @addtogroup USBD_OTG_DRIVER
  * @{
  */

/** @defgroup USBD_DEVICE USBD_DEVICE
  * @brief Device file for Usb otg low level driver.
  * @{
  */

/** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables
  * @brief Public variables.
  * @{
  */

/** USB device core handle. */
extern USBD_HandleTypeDef hUsbDeviceFS;

/**
  * @}
  */

/** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype
  * @brief Declaration of public functions for Usb device.
  * @{
  */

/** USB Device initialization function. */
void MX_USB_DEVICE_Init(void);

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif /* __USB_DEVICE__H__ */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/




























//                            usbd_cdc_if.h



/**
  ******************************************************************************
  * @file           : usbd_cdc_if.h
  * @version        : v2.0_Cube
  * @brief          : Header for usbd_cdc_if.c file.
  ******************************************************************************
  * This notice applies to any and all portions of this file
  * that are not between comment pairs USER CODE BEGIN and
  * USER CODE END. Other portions of this file, whether 
  * inserted by the user or by software development tools
  * are owned by their respective copyright owners.
  *
  * Copyright (c) 2019 STMicroelectronics International N.V. 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without 
  * modification, are permitted, provided that the following conditions are met:
  *
  * 1. Redistribution of source code must retain the above copyright notice, 
  *    this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright notice,
  *    this list of conditions and the following disclaimer in the documentation
  *    and/or other materials provided with the distribution.
  * 3. Neither the name of STMicroelectronics nor the names of other 
  *    contributors to this software may be used to endorse or promote products 
  *    derived from this software without specific written permission.
  * 4. This software, including modifications and/or derivative works of this 
  *    software, must execute solely and exclusively on microcontroller or
  *    microprocessor devices manufactured by or for STMicroelectronics.
  * 5. Redistribution and use of this software other than as permitted under 
  *    this license is void and will automatically terminate your rights under 
  *    this license. 
  *
  * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 
  * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
  * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
  * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 
  * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_CDC_IF_H__
#define __USBD_CDC_IF_H__

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "usbd_cdc.h"
#include "Types.h"
/* USER CODE BEGIN INCLUDE */

/* USER CODE END INCLUDE */

/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
  * @brief For Usb device.
  * @{
  */
  
/** @defgroup USBD_CDC_IF USBD_CDC_IF
  * @brief Usb VCP device module
  * @{
  */ 

/** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines
  * @brief Defines.
  * @{
  */
/* USER CODE BEGIN EXPORTED_DEFINES */

/* USER CODE END EXPORTED_DEFINES */

/**
  * @}
  */

/** @defgroup USBD_CDC_IF_Exported_Types USBD_CDC_IF_Exported_Types
  * @brief Types.
  * @{
  */

/* USER CODE BEGIN EXPORTED_TYPES */

/* USER CODE END EXPORTED_TYPES */

/**
  * @}
  */

/** @defgroup USBD_CDC_IF_Exported_Macros USBD_CDC_IF_Exported_Macros
  * @brief Aliases.
  * @{
  */

/* USER CODE BEGIN EXPORTED_MACRO */

/* USER CODE END EXPORTED_MACRO */

/**
  * @}
  */

/** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables
  * @brief Public variables.
  * @{
  */

/** CDC Interface callback. */
extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS;

/* USER CODE BEGIN EXPORTED_VARIABLES */

/* USER CODE END EXPORTED_VARIABLES */

/**
  * @}
  */

/** @defgroup USBD_CDC_IF_Exported_FunctionsPrototype USBD_CDC_IF_Exported_FunctionsPrototype
  * @brief Public functions declaration.
  * @{
  */

uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len);

/* USER CODE BEGIN EXPORTED_FUNCTIONS */

/* USER CODE END EXPORTED_FUNCTIONS */

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

void USB_Send(BYTE *pBuf, UINT16 len);
void USB_EndReceive(void);
void USB_ReceiveISR(BYTE *pBuf, UINT16 len);

#ifdef __cplusplus
}
#endif

#endif /* __USBD_CDC_IF_H__ */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
  
                     

























//                                    usbd_conf.h



/**
  ******************************************************************************
  * @file           : usbd_conf.h
  * @version        : v2.0_Cube
  * @brief          : Header for usbd_conf.c file.
  ******************************************************************************
  * This notice applies to any and all portions of this file
  * that are not between comment pairs USER CODE BEGIN and
  * USER CODE END. Other portions of this file, whether 
  * inserted by the user or by software development tools
  * are owned by their respective copyright owners.
  *
  * Copyright (c) 2020 STMicroelectronics International N.V. 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without 
  * modification, are permitted, provided that the following conditions are met:
  *
  * 1. Redistribution of source code must retain the above copyright notice, 
  *    this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright notice,
  *    this list of conditions and the following disclaimer in the documentation
  *    and/or other materials provided with the distribution.
  * 3. Neither the name of STMicroelectronics nor the names of other 
  *    contributors to this software may be used to endorse or promote products 
  *    derived from this software without specific written permission.
  * 4. This software, including modifications and/or derivative works of this 
  *    software, must execute solely and exclusively on microcontroller or
  *    microprocessor devices manufactured by or for STMicroelectronics.
  * 5. Redistribution and use of this software other than as permitted under 
  *    this license is void and will automatically terminate your rights under 
  *    this license. 
  *
  * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 
  * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
  * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
  * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 
  * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_CONF__H__
#define __USBD_CONF__H__

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stm32f1xx.h"
#include "stm32f1xx_hal.h"
#include "usbd_def.h"

/* USER CODE BEGIN INCLUDE */

/* USER CODE END INCLUDE */

/** @addtogroup USBD_OTG_DRIVER
  * @{
  */

/** @defgroup USBD_CONF USBD_CONF
  * @brief Configuration file for Usb otg low level driver.
  * @{
  */

/** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables
  * @brief Public variables.
  * @{
  */

/**
  * @}
  */

/** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines
  * @brief Defines for configuration of the Usb device.
  * @{
  */

/*---------- -----------*/
#define USBD_MAX_NUM_INTERFACES     1
/*---------- -----------*/
#define USBD_MAX_NUM_CONFIGURATION     1
/*---------- -----------*/
#define USBD_MAX_STR_DESC_SIZ     512
/*---------- -----------*/
#define USBD_SUPPORT_USER_STRING     0
/*---------- -----------*/
#define USBD_DEBUG_LEVEL     0
/*---------- -----------*/
#define USBD_SELF_POWERED     1
/*---------- -----------*/

/****************************************/
/* #define for FS and HS identification */
#define DEVICE_FS 		0

/**
  * @}
  */

/** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros
  * @brief Aliases.
  * @{
  */

/* Memory management macros */

/** Alias for memory allocation. */
#define USBD_malloc         malloc

/** Alias for memory release. */
#define USBD_free           free

/** Alias for memory set. */
#define USBD_memset         memset

/** Alias for memory copy. */
#define USBD_memcpy         memcpy

/** Alias for delay. */
#define USBD_Delay          HAL_Delay

/* DEBUG macros */

#if (USBD_DEBUG_LEVEL > 0)
#define USBD_UsrLog(...)    printf(__VA_ARGS__);\
                            printf("\n");
#else
#define USBD_UsrLog(...)
#endif

#if (USBD_DEBUG_LEVEL > 1)

#define USBD_ErrLog(...)    printf("ERROR: ") ;\
                            printf(__VA_ARGS__);\
                            printf("\n");
#else
#define USBD_ErrLog(...)
#endif

#if (USBD_DEBUG_LEVEL > 2)
#define USBD_DbgLog(...)    printf("DEBUG : ") ;\
                            printf(__VA_ARGS__);\
                            printf("\n");
#else
#define USBD_DbgLog(...)
#endif

/**
  * @}
  */

/** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types
  * @brief Types.
  * @{
  */

/**
  * @}
  */

/** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype
  * @brief Declaration of public functions for Usb device.
  * @{
  */

/* Exported functions -------------------------------------------------------*/

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif /* __USBD_CONF__H__ */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/






























//                                 usbd_desc.h



/**
  ******************************************************************************
  * @file           : usbd_desc.h
  * @version        : v2.0_Cube
  * @brief          : Header for usbd_conf.c file.
  ******************************************************************************
  * This notice applies to any and all portions of this file
  * that are not between comment pairs USER CODE BEGIN and
  * USER CODE END. Other portions of this file, whether 
  * inserted by the user or by software development tools
  * are owned by their respective copyright owners.
  *
  * Copyright (c) 2020 STMicroelectronics International N.V. 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without 
  * modification, are permitted, provided that the following conditions are met:
  *
  * 1. Redistribution of source code must retain the above copyright notice, 
  *    this list of conditions and the following disclaimer.
  * 2. Redistributions in binary form must reproduce the above copyright notice,
  *    this list of conditions and the following disclaimer in the documentation
  *    and/or other materials provided with the distribution.
  * 3. Neither the name of STMicroelectronics nor the names of other 
  *    contributors to this software may be used to endorse or promote products 
  *    derived from this software without specific written permission.
  * 4. This software, including modifications and/or derivative works of this 
  *    software, must execute solely and exclusively on microcontroller or
  *    microprocessor devices manufactured by or for STMicroelectronics.
  * 5. Redistribution and use of this software other than as permitted under 
  *    this license is void and will automatically terminate your rights under 
  *    this license. 
  *
  * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 
  * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 
  * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
  * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 
  * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  ******************************************************************************
  */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __USBD_DESC__H__
#define __USBD_DESC__H__

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "usbd_def.h"

/* USER CODE BEGIN INCLUDE */

/* USER CODE END INCLUDE */

/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
  * @{
  */

/** @defgroup USBD_DESC USBD_DESC
  * @brief Usb device descriptors module.
  * @{
  */

/** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines
  * @brief Defines.
  * @{
  */

/* USER CODE BEGIN EXPORTED_DEFINES */

/* USER CODE END EXPORTED_DEFINES */

/**
  * @}
  */

/** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions
  * @brief Types.
  * @{
  */

/* USER CODE BEGIN EXPORTED_TYPES */

/* USER CODE END EXPORTED_TYPES */

/**
  * @}
  */

/** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros
  * @brief Aliases.
  * @{
  */

/* USER CODE BEGIN EXPORTED_MACRO */

/* USER CODE END EXPORTED_MACRO */

/**
  * @}
  */

/** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables
  * @brief Public variables.
  * @{
  */

/** Descriptor for the Usb device. */
extern USBD_DescriptorsTypeDef FS_Desc;

/* USER CODE BEGIN EXPORTED_VARIABLES */

/* USER CODE END EXPORTED_VARIABLES */

/**
  * @}
  */

/** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype
  * @brief Public functions declaration.
  * @{
  */

/* USER CODE BEGIN EXPORTED_FUNCTIONS */

/* USER CODE END EXPORTED_FUNCTIONS */

/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif /* __USBD_DESC__H__ */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值