1 /********************************** (C) COPYRIGHT ******************************* 2 * File Name : ch32f20x_opa.h 3 * Author : WCH 4 * Version : V1.0.0 5 * Date : 2021/08/08 6 * Description : This file contains all the functions prototypes for the 7 * OPA firmware library. 8 *******************************************************************************/ 9 #ifndef __CH32F20x_OPA_H 10 #define __CH32F20x_OPA_H 11 12 #ifdef __cplusplus 13 extern "C" { 14 #endif 15 16 #include "ch32F20x.h" 17 18 #define OPA_PSEL_OFFSET 3 19 #define OPA_NSEL_OFFSET 2 20 #define OPA_MODE_OFFSET 1 21 22 23 /* OPA member enumeration */ 24 typedef enum 25 { 26 OPA1=0, 27 OPA2, 28 OPA3, 29 OPA4 30 }OPA_Num_TypeDef; 31 32 /* OPA PSEL enumeration */ 33 typedef enum 34 { 35 CHP0=0, 36 CHP1 37 }OPA_PSEL_TypeDef; 38 39 /* OPA NSEL enumeration */ 40 typedef enum 41 { 42 CHN0=0, 43 CHN1 44 }OPA_NSEL_TypeDef; 45 46 /* OPA Mode enumeration */ 47 typedef enum 48 { 49 OUT_IO_ADC=0, 50 OUT_IO 51 }OPA_Mode_TypeDef; 52 53 /* OPA Init Structure definition */ 54 typedef struct 55 { 56 OPA_Num_TypeDef OPA_NUM; /* Specifies the members of OPA */ 57 OPA_PSEL_TypeDef PSEL; /* Specifies the positive channel of OPA */ 58 OPA_NSEL_TypeDef NSEL; /* Specifies the negative channel of OPA */ 59 OPA_Mode_TypeDef Mode; /* Specifies the mode of OPA */ 60 }OPA_InitTypeDef; 61 62 void OPA_DeInit(void); 63 void OPA_Init(OPA_InitTypeDef* OPA_InitStruct); 64 void OPA_StructInit(OPA_InitTypeDef* OPA_InitStruct); 65 void OPA_Cmd(OPA_Num_TypeDef OPA_NUM, FunctionalState NewState); 66 67 #ifdef __cplusplus 68 } 69 #endif 70 71 #endif 72 73