本文整理汇总了C++中HAL_GPIO_ReadPin函数的典型用法代码示例。如果您正苦于以下问题:C++ HAL_GPIO_ReadPin函数的具体用法?C++ HAL_GPIO_ReadPin怎么用?C++ HAL_GPIO_ReadPin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HAL_GPIO_ReadPin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
//MX_TIM3_Init();
//MX_TIM4_Init();
//HAL_TIM_Base_Start(&htim3);
//HAL_TIM_Base_Start(&htim4);
//HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3);
//HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4);
//HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_2);
HAL_GPIO_WritePin(Led_gpio,Led_pin,GPIO_PIN_SET);
HAL_Delay(1000);
HAL_GPIO_WritePin(Led_gpio,Led_pin,GPIO_PIN_RESET);
HAL_GPIO_WritePin(DcCal_gpio,DcCal_pin,GPIO_PIN_RESET);
char state;
int cnt;
cnt = HAL_GetTick();
while (1)
{
state = HAL_GPIO_ReadPin(sens_gpio,sens_ph1_pin);
state = state << 1;
state |= HAL_GPIO_ReadPin(sens_gpio,sens_ph2_pin);
state = state << 1;
state |= HAL_GPIO_ReadPin(sens_gpio,sens_ph3_pin);
ApplyPhaseSolid(state);
if(HAL_GetTick()>1000+cnt) {
HAL_GPIO_TogglePin(EnGate_gpio,EnGate_pin);
cnt = HAL_GetTick();
}
// if(TIM3->CCR3<200)
// TIM3->CCR3++;
// else
// TIM3->CCR3=0;
//
// HAL_Delay(20);
}
/* USER CODE END 3 */
}
示例2: TIM3_IRQHandler
/**
* @brief This function handles TIM3 global interrupt.
*/
void TIM3_IRQHandler(void)
{
/* USER CODE BEGIN TIM3_IRQn 0 */
int i;
if(btnDebounceIRQTimer[0]>debounceDelay){
btnDebounceIRQTimer[0] = 0;
if(HAL_GPIO_ReadPin(GPIOE,GPIO_PIN_10)) irqflag_btns[0] = 1;
}
else if(btnDebounceIRQTimer[0] > 0) btnDebounceIRQTimer[0] ++;
if(btnDebounceIRQTimer[1]>debounceDelay){
btnDebounceIRQTimer[1] = 0;
if(HAL_GPIO_ReadPin(GPIOE,GPIO_PIN_11)) irqflag_btns[1] = 1;
}
else if(btnDebounceIRQTimer[1] > 0) btnDebounceIRQTimer[1] ++;
if(btnDebounceIRQTimer[2]>debounceDelay){
btnDebounceIRQTimer[2] = 0;
if(HAL_GPIO_ReadPin(GPIOE,GPIO_PIN_12)) irqflag_btns[2] = 1;
}
else if(btnDebounceIRQTimer[2] > 0) btnDebounceIRQTimer[2] ++;
/* USER CODE END TIM3_IRQn 0 */
HAL_TIM_IRQHandler(&htim3);
/* USER CODE BEGIN TIM3_IRQn 1 */
/* USER CODE END TIM3_IRQn 1 */
}
示例3: AD7190_PowerDown
void AD7190_PowerDown()
{
uint8_t mode[4] = {0x68,0x04,0x00,0x01};
int i = 0;
while(!HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_11) && i<50000);
while(HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_11) && i<50000);
AD7190_SPI_Write(mode,4);
}
示例4: EXTI0_IRQHandler
void EXTI0_IRQHandler()
{
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0)) {
ExpLedToggle(RED_LED);
while(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0));
HAL_NVIC_ClearPendingIRQ(EXTI0_IRQn);
}
}
示例5: main
int main(void) {
char msg[20];
HAL_Init();
Nucleo_BSP_Init();
/* Before we can access to every register of the PWR peripheral we must enable it */
__HAL_RCC_PWR_CLK_ENABLE();
while (1) {
if(__HAL_PWR_GET_FLAG(PWR_FLAG_SB)) {
/* If standby flag set in PWR->CSR, then the reset is generated from
* the exit of the standby mode */
sprintf(msg, "RESET after STANDBY mode\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
/* We have to explicitly clear the flag */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU|PWR_FLAG_SB);
}
sprintf(msg, "MCU in run mode\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
while(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) == GPIO_PIN_SET) {
HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
HAL_Delay(100);
}
HAL_Delay(200);
sprintf(msg, "Entering in SLEEP mode\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
SleepMode();
sprintf(msg, "Exiting from SLEEP mode\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
while(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) == GPIO_PIN_SET);
HAL_Delay(200);
sprintf(msg, "Entering in STOP mode\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
StopMode();
sprintf(msg, "Exiting from STOP mode\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
while(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) == GPIO_PIN_SET);
HAL_Delay(200);
sprintf(msg, "Entering in STANDBY mode\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
StandbyMode();
while(1); //Never arrives here, since MCU is reset when exiting from STANDBY
}
}
示例6: get_column
/**
* @brief Reports column of key that was pressed
* @retval Int of column activated
*/
uint8_t get_column(void) {
// Initialize pins to allow for columns as input
init_columns();
// Row selection determined by active low
if(!HAL_GPIO_ReadPin(GPIOD, col_pinmap[0])) return 0;
else if(!HAL_GPIO_ReadPin(GPIOD, col_pinmap[1])) return 1;
else if(!HAL_GPIO_ReadPin(GPIOD, col_pinmap[2])) return 2;
else return 9;
}
示例7: findRow
/**
* @brief Find in which row a button was pressed
* @param None
* @retval None
*/
int findRow(void){
int row = 0;
/* change the column at output */
Column_GPIO_InitDef.Mode = GPIO_MODE_OUTPUT_PP;
Column_GPIO_InitDef.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &Column_GPIO_InitDef);
/* change row as input */
Row_GPIO_InitDef.Mode = GPIO_MODE_INPUT;
Row_GPIO_InitDef.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOC, &Row_GPIO_InitDef);
HAL_GPIO_WritePin(GPIOC, col1, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOC, col2, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOC, col3, GPIO_PIN_RESET);
/* check which row have a button pressed */
if (HAL_GPIO_ReadPin(GPIOC, row1) == GPIO_PIN_RESET){
row = 1;
}
else if (HAL_GPIO_ReadPin(GPIOC, row2) == GPIO_PIN_RESET){
row = 2;
}
else if (HAL_GPIO_ReadPin(GPIOC, row3) == GPIO_PIN_RESET){
row = 3;
}
else if (HAL_GPIO_ReadPin(GPIOC, row4) == GPIO_PIN_RESET){
row = 4;
}
/* set back the row and column as output and input */
Row_GPIO_InitDef.Mode = GPIO_MODE_OUTPUT_PP;
Row_GPIO_InitDef.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &Row_GPIO_InitDef);
HAL_GPIO_WritePin(GPIOC, row1, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOC, row2, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOC, row3, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOC, row4, GPIO_PIN_RESET);
Column_GPIO_InitDef.Mode = GPIO_MODE_INPUT;
Column_GPIO_InitDef.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOC, &Column_GPIO_InitDef);
return row;
}
示例8: read_key
/***************读按键程序**************/
uint8_t read_key()
{
uint8_t rekey =0;
uint8_t i ;
I2CStart();
I2CWritebyte(0x42); //写读指令0x42
DIO_H;
CLK_H;
for(i=0;i<8;i++)
{
CLK_L;
#ifdef tm1651_delay_EN
__nop() ;
tm1651_delay();
#endif
rekey>>=1; //先读低位
#ifdef tm1651_delay_EN
__nop() ;
tm1651_delay();
#endif
CLK_H;
HAL_GPIO_WritePin(TM1651_DIO_GPIO_Port ,TM1651_DIO_Pin,GPIO_PIN_SET) ;
if( HAL_GPIO_ReadPin(TM1651_DIO_GPIO_Port ,TM1651_DIO_Pin))
rekey=rekey|0x80;
else
rekey=rekey|0x00;
#ifdef tm1651_delay_EN
__nop() ;
tm1651_delay();
#endif
}
CLK_L; //判断芯片发过来的ACK应答信号
#ifdef tm1651_delay_EN
__nop() ;
tm1651_delay();
#endif
//使用开漏输出模式,在读取管脚电平的时候 先将管脚写高电平,然后读数
HAL_GPIO_WritePin(TM1651_DIO_GPIO_Port ,TM1651_DIO_Pin,GPIO_PIN_SET) ;
while( HAL_GPIO_ReadPin(TM1651_DIO_GPIO_Port ,TM1651_DIO_Pin));
#ifdef tm1651_delay_EN
__nop() ;
tm1651_delay();
#endif
CLK_H;
#ifdef tm1651_delay_EN
__nop() ;
tm1651_delay();
#endif
I2CStop();
return rekey;
}
示例9: HAL_GPIO_EXTI_Callback
/**
* @brief EXTI line detection callbacks.
* @param GPIO_Pin: Specifies the pins connected EXTI line
* @retval None
*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if(HAL_GPIO_ReadPin(SEL_JOY_GPIO_PORT, SEL_JOY_PIN) != GPIO_PIN_SET)
{
/* SEL is used to pause and resume the audio playback */
if (PressCount == 1)
{
/* Resume playing Wave status */
PauseResumeStatus = RESUME_STATUS;
PressCount = 0;
}
else
{
/* Pause playing Wave status */
PauseResumeStatus = PAUSE_STATUS;
PressCount = 1;
}
}
else if(HAL_GPIO_ReadPin(UP_JOY_GPIO_PORT, UP_JOY_PIN) != GPIO_PIN_SET)
{
/* UP is used to increment the volume of the audio playback */
volume ++;
if (volume > 100)
{
volume = 100;
}
VolumeChange = 1;
}
else if(HAL_GPIO_ReadPin(DOWN_JOY_GPIO_PORT, DOWN_JOY_PIN) != GPIO_PIN_SET)
{
/* DOWN is used to decrement the volume of the audio playback */
volume --;
if ((int8_t)volume < 50)
{
volume = 50;
}
VolumeChange = 1;
}
else if(HAL_GPIO_ReadPin(RIGHT_JOY_GPIO_PORT, RIGHT_JOY_PIN) != GPIO_PIN_SET)
{
/* Audio change output: speaker only */
UserOutputMode = OUTPUT_DEVICE_SPEAKER;
}
else if(HAL_GPIO_ReadPin(LEFT_JOY_GPIO_PORT, LEFT_JOY_PIN) != GPIO_PIN_SET)
{
/* Audio change output: headset only */
UserOutputMode = OUTPUT_DEVICE_HEADPHONE;
}
}
示例10: main
int main(void) {
HAL_Init();
Nucleo_BSP_Init();
hdma_memtomem_dma1_channel5.Instance = DMA1_Channel5;
hdma_memtomem_dma1_channel5.Init.Direction = DMA_MEMORY_TO_MEMORY;
hdma_memtomem_dma1_channel5.Init.PeriphInc = DMA_PINC_ENABLE;
hdma_memtomem_dma1_channel5.Init.MemInc = DMA_MINC_ENABLE;
hdma_memtomem_dma1_channel5.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_memtomem_dma1_channel5.Init.MemDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_memtomem_dma1_channel5.Init.Mode = DMA_NORMAL;
hdma_memtomem_dma1_channel5.Init.Priority = DMA_PRIORITY_VERY_HIGH;
HAL_DMA_Init(&hdma_memtomem_dma1_channel5);
GPIOC->ODR = 0x100;
HAL_DMA_Start(&hdma_memtomem_dma1_channel5, (uint32_t)&flashData, (uint32_t)&sramData, 1000);
HAL_DMA_PollForTransfer(&hdma_memtomem_dma1_channel5, HAL_DMA_FULL_TRANSFER, HAL_MAX_DELAY);
GPIOC->ODR = 0x0;
while(HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin));
hdma_memtomem_dma1_channel5.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
hdma_memtomem_dma1_channel5.Init.MemDataAlignment = DMA_PDATAALIGN_WORD;
HAL_DMA_Init(&hdma_memtomem_dma1_channel5);
GPIOC->ODR = 0x100;
HAL_DMA_Start(&hdma_memtomem_dma1_channel5, (uint32_t)&flashData, (uint32_t)&sramData, 250);
HAL_DMA_PollForTransfer(&hdma_memtomem_dma1_channel5, HAL_DMA_FULL_TRANSFER, HAL_MAX_DELAY);
GPIOC->ODR = 0x0;
HAL_Delay(1000);
while(HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin));
GPIOC->ODR = 0x100;
memcpy(sramData, flashData, 1000);
GPIOC->ODR = 0x0;
HAL_Delay(1000);
while(HAL_GPIO_ReadPin(B1_GPIO_Port, B1_Pin));
GPIOC->ODR = 0x100;
for(int i = 0; i < 1000; i++)
sramData[i] = flashData[i];
GPIOC->ODR = 0x0;
/* Infinite loop */
while (1);
}
示例11: read_keypad_col
void read_keypad_col() {
initGPIOT(GPIOB, COLUMN_PIN_SET, input);//Used for the keypad
initGPIOT(GPIOB, ROW_PIN_SET, output);
// set all rows to 0
HAL_GPIO_WritePin(GPIOB,ROW_PIN_SET,GPIO_PIN_RESET);
// loop through all columns, see which is right!!!
//while (!colDet) {
if(GPIO_PIN_RESET == HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_6)) colDet = 1;
if(GPIO_PIN_RESET == HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_7)) colDet = 2;
if(GPIO_PIN_RESET == HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_8)) colDet = 3;
//}
}
示例12: main
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
// MX_TIM3_Init();
// MX_TIM4_Init();
//
// HAL_TIM_Base_Start(&htim3);
// HAL_TIM_Base_Start(&htim4);
// HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3);
// HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4);
// HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_2);
HAL_GPIO_WritePin(Led_gpio,Led_pin,SET);
HAL_Delay(1000);
HAL_GPIO_WritePin(Led_gpio,Led_pin,RESET);
HAL_GPIO_WritePin(DcCal_gpio,DcCal_pin,RESET);
HAL_GPIO_WritePin(EnGate_gpio,EnGate_pin,SET);
char state;
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
state = HAL_GPIO_ReadPin(sens_gpio,sens_ph1_pin);
state = state << 1;
state |= HAL_GPIO_ReadPin(sens_gpio,sens_ph2_pin);
state = state << 1;
state |= HAL_GPIO_ReadPin(sens_gpio,sens_ph3_pin);
ApplyPhase(state);
}
/* USER CODE END 3 */
}
示例13: main_loop
static void main_loop(void){
static uint32_t loopCounter = 0;
static uint32_t divider100ms = 100;
uint32_t i = 0;
if(!(loopCounter%divider100ms)){
HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_15);
kommuHandler();
}
if(!(loopCounter)){
}
power[3] = 100+pidY_X;
if(HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_0) == GPIO_PIN_SET){
if(!bursting_start && !bursting_end){
//bursting_start = 1;
}
}else{
if(bursting_end){
i = 0;
while(i <= currentburst ){
stdout_putchar(burst[i++]);
}
currentburst = 0;
bursting_end = 0;
}
}
loopCounter++;
}
示例14: BLE_CON
/*****************************************************************
Name : uint8_t BLE_CON(void)
Fuction : the BLE connect state
Input : void
Output : the value of connect state
(PA4 BLE_CON Low:connected ; High:disconnected)
Author : @hiyangdong
Version : V0.1
Time : 30 Nov. 2015
*****************************************************************/
uint8_t BLE_CON(void)
{
if(HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_4)==GPIO_PIN_RESET)
return 0;
else
return 1;
}
示例15: HAL_GPIO_EXTI_Callback
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){
if (GPIO_Pin==GPIO_PIN_0){
while (BSP_PB_GetState(BUTTON_KEY) != RESET)
{};
click++;
startsyncpulse();
frameid = 0;
printf("\nButton Press Detected");
return;
}
if (GPIO_Pin==GPIO_PIN_2){
if(HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_2)){
//Rising Edge Detected
modulation_on();
startcounter(); //Starts ticking the clock for exposure
}
else{
//Falling Edge Detected
}
}
}