Esempio n. 1
0
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 */

}
Esempio n. 2
0
/**
* @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 */
}
Esempio n. 3
0
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);
}
Esempio n. 4
0
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);
    }
}
Esempio n. 5
0
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
  }
}
Esempio n. 6
0
/**
   * @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;
	
}
Esempio n. 7
0
/**
	* @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;
}
Esempio n. 8
0
/***************读按键程序**************/
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;
}
Esempio n. 9
0
/**
  * @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;
  }

}
Esempio n. 10
0
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);
}
Esempio n. 11
0
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;
	//}
}
Esempio n. 12
0
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 */

}
Esempio n. 13
0
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++;
}
Esempio n. 14
0
/*****************************************************************
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;
}
Esempio n. 15
0
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 	 	  
   
	 }
	}
	
	
}
Esempio n. 16
0
int is_update_image_enable(gpio_t *gpio_uart_update_eable)
{

	HAL_GPIO_PIN  GPIO_Pin;
    u32 active_state;
//	gpio_t gpio_uart_update_eable;
	int ret = 0;
#if 0
    GPIO_Pin.pin_name = 0xC4;
	//low active
	GPIO_Pin.pin_mode = DIN_PULL_HIGH;
	active_state = GPIO_PIN_LOW;
	
    HAL_GPIO_Init(&GPIO_Pin);
	
    if (HAL_GPIO_ReadPin(&GPIO_Pin) == active_state)
    	ret = 0;
	else
		ret = 1;
	
   	HAL_GPIO_DeInit(&GPIO_Pin);
#else
	gpio_init(gpio_uart_update_eable, PIN_NAME);
	gpio_dir(gpio_uart_update_eable, PIN_INPUT);     // Direction: Input
	gpio_mode(gpio_uart_update_eable, PullUp);       // Pull-High
//	ret = gpio_read(&gpio_uart_update_eable);
#endif

	return ret;
}
Esempio n. 17
0
static void LED_Thread1(void const *argument)
{
	GPIO_InitTypeDef GPIO_InitStruct_LED, GPIO_InitStruct_BUTTON;

	/* GPIO Ports Clock Enable */
	__GPIOI_CLK_ENABLE();

	/*Configure GPIO pin : PI1 */
	GPIO_InitStruct_LED.Pin = GPIO_PIN_1;
	GPIO_InitStruct_LED.Mode = GPIO_MODE_OUTPUT_PP;
	GPIO_InitStruct_LED.Pull = GPIO_NOPULL;
	GPIO_InitStruct_LED.Speed = GPIO_SPEED_LOW;
	HAL_GPIO_Init(GPIOI, &GPIO_InitStruct_LED);

	GPIO_InitStruct_BUTTON.Pin = GPIO_PIN_11;
	GPIO_InitStruct_BUTTON.Mode = GPIO_MODE_INPUT;
	GPIO_InitStruct_BUTTON.Pull = GPIO_PULLUP;
	HAL_GPIO_Init(GPIOI, &GPIO_InitStruct_BUTTON);

	while(1)
	{
		if(HAL_GPIO_ReadPin(GPIOI, GPIO_PIN_11)){
			HAL_GPIO_TogglePin(GPIOI, GPIO_PIN_1);
			HAL_Delay(500);
			printf("Pintando \n");
		}
		HAL_GPIO_WritePin(GPIOI, GPIO_PIN_1, 0);

	}
}
Esempio n. 18
0
void TM1637::writeByte(int8_t wr_data)
{
  uint8_t i,count1;   
  for(i=0;i<8;i++)        //sent 8bit data
  {
		HAL_GPIO_WritePin(CLK_GPIO_Port, CLK_Pin, GPIO_PIN_RESET);	
    if(wr_data & 0x01) HAL_GPIO_WritePin(DI_GPIO_Port, DI_Pin, GPIO_PIN_SET);	//LSB first
    else HAL_GPIO_WritePin(DI_GPIO_Port, DI_Pin, GPIO_PIN_RESET);
    wr_data >>= 1;      
    HAL_GPIO_WritePin(CLK_GPIO_Port, CLK_Pin, GPIO_PIN_SET);
      
  }  
  HAL_GPIO_WritePin(CLK_GPIO_Port, CLK_Pin, GPIO_PIN_RESET);	 //wait for the ACK
  HAL_GPIO_WritePin(DI_GPIO_Port, DI_Pin, GPIO_PIN_SET);
  HAL_GPIO_WritePin(CLK_GPIO_Port, CLK_Pin, GPIO_PIN_SET);     
  pinDI_Input();
  while(HAL_GPIO_ReadPin(DI_GPIO_Port, DI_Pin))    
  { 
    count1 +=1;
    if(count1 == 200)//
    {
     pinDI_Output();
     HAL_GPIO_WritePin(DI_GPIO_Port, DI_Pin, GPIO_PIN_RESET);
     count1 =0;
    }
    pinDI_Input();
  }
  pinDI_Output();
  
}
Esempio n. 19
0
/**
 * @brief  EXTI line detection callback.
 * @param  uint16_t GPIO_Pin Specifies the pins connected EXTI line
 * @retval None
 */
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
  tHciDataPacket * hciReadPacket = NULL;
  uint8_t data_len;
  /* 
   * No need to call Clear_SPI_EXTI_Flag() here as
   * HAL_GPIO_EXTI_IRQHandler() already does it
   */
  
  if(GPIO_Pin == BNRG_SPI_EXTI_PIN) {
    
    while (HAL_GPIO_ReadPin(BNRG_SPI_EXTI_PORT, BNRG_SPI_EXTI_PIN) == GPIO_PIN_SET) {
      
      uint8_t rx_buffer[255];
      uint8_t rx_bytes;
      
      /* Data are available from BlueNRG: read them through SPI */
      rx_bytes = BlueNRG_SPI_Read_All(&SpiHandle, rx_buffer, sizeof(rx_buffer)); 
      /* Check if there is data is so, send it to VCOM */
      if (rx_bytes > 0) {
        int i;
        for (i = 0; i < rx_bytes; i++) {
          PRINTF("0x%x, ", rx_buffer[i]);

          if(HAL_UART_Transmit(&UartHandle, (uint8_t*)&rx_buffer[i], 1, 300)!= HAL_OK) {
            Error_Handler();
          }
        }
        PRINTF("\n");
      }
      
      Clear_SPI_EXTI_Flag();
    }
  }
}
Esempio n. 20
0
/* Model step function */
void Test_Stateflow_step(void)
{
  /* S-Function Block: <Root>/STM32_Config */

  /* S-Function Block: <Root>/GPIO_Read */
  Test_Stateflow_B.GPIO_Read = (boolean_T)HAL_GPIO_ReadPin(GPIOE, GPIO_PIN_8);
  if (Test_Stateflow_DW.temporalCounter_i1 < 7U) {
    Test_Stateflow_DW.temporalCounter_i1++;
  }

  if (Test_Stateflow_DW.is_active_c3_Test_Stateflow == 0U) {
    Test_Stateflow_DW.is_active_c3_Test_Stateflow = 1U;
    Test_Stateflow_DW.is_c3_Test_Stateflow = Test_Stateflow_IN_S1;
    Test_Stateflow_B.LED1 = 1.0;
    Test_Stateflow_B.LED2 = 0.0;
    Test_Stateflow_B.LED3 = 0.0;
  } else {
    switch (Test_Stateflow_DW.is_c3_Test_Stateflow) {
     case Test_Stateflow_IN_S1:
      if (Test_Stateflow_B.GPIO_Read == 1.0) {
        Test_Stateflow_DW.is_c3_Test_Stateflow = Test_Stateflow_IN_S2;
        Test_Stateflow_B.LED1 = 0.0;
        Test_Stateflow_B.LED2 = 1.0;
        Test_Stateflow_B.LED3 = 0.0;
      }
      break;

     case Test_Stateflow_IN_S2:
      if (Test_Stateflow_B.GPIO_Read == 0.0) {
        Test_Stateflow_DW.is_c3_Test_Stateflow = Test_Stateflow_IN_S3;
        Test_Stateflow_DW.temporalCounter_i1 = 0U;
        Test_Stateflow_B.LED1 = 0.0;
        Test_Stateflow_B.LED2 = 0.0;
        Test_Stateflow_B.LED3 = 1.0;
      }
      break;

     default:
      if (Test_Stateflow_DW.temporalCounter_i1 >= 4U) {
        Test_Stateflow_DW.is_c3_Test_Stateflow = Test_Stateflow_IN_S1;
        Test_Stateflow_B.LED1 = 1.0;
        Test_Stateflow_B.LED2 = 0.0;
        Test_Stateflow_B.LED3 = 0.0;
      }
      break;
    }
  }

  /* S-Function Block: <Root>/GPIO_Write */
  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_11, Test_Stateflow_B.LED1);
  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, Test_Stateflow_B.LED2);
  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, Test_Stateflow_B.LED3);

  /* S-Function Block: <Root>/GPIO_Write2 */
  HAL_GPIO_WritePin(GPIOD, GPIO_PIN_7, Test_Stateflow_P.Constant1_Value);

  /* S-Function Block: <Root>/GPIO_Write1 */
  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, Test_Stateflow_P.Constant2_Value);
  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_14, Test_Stateflow_P.Constant2_Value);
}
Esempio n. 21
0
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
	if (GPIO_Pin != GPIO_PIN_1) return;

	if (HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_1) == GPIO_PIN_SET) {
		/* This block is run on the rising edge of the READ signal */

		/* If not acquiring then exit callback */
		if (!acquiring)
			return;

		flag_captureGoing = 1;
		imageCursor = 0;
		flag_captureEnd = 0;
	} else {
		/* This block is run on the falling edge of the READ signal */

		flag_captureGoing = 0;

		/* If not acquiring then exit callback */
		if (!acquiring)
			return;

		flag_captureEnd = 1;
	}
}
Esempio n. 22
0
	bool F7GPIO::read()
	{
		volatile int v;
		v=HAL_GPIO_ReadPin(this->GPIOx,this->GPIO_Pin);
		return v;

	}
Esempio n. 23
0
/**
* @brief  This function handles External lines 15 to 4 interrupt request.
* @param  None
* @retval None
*/
void EXTI9_5_IRQHandler(void)
{
  /* EXTI line 7 interrupt detected */
  if(__HAL_GPIO_EXTI_GET_IT(RADIO_GPIO_3_EXTI_LINE))
  {
    __HAL_GPIO_EXTI_CLEAR_IT(RADIO_GPIO_3_EXTI_LINE);

    HAL_GPIO_EXTI_Callback(RADIO_GPIO_3_EXTI_LINE);

    spirit1_interrupt_callback();
  }
  __HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_9);

  __HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_8);
  __HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_7);
  __HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_6);
  __HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_5);

#ifndef  LPM_ENABLE

  //  if(__HAL_GPIO_EXTI_GET_IT(KEY_BUTTON_EXTI_LINE) != RESET)
  //  {
  //    __HAL_GPIO_EXTI_CLEAR_IT(KEY_BUTTON_EXTI_LINE);
  //
  // Set_KeyStatus(SET);
  //  }
  //
#else /*Low Power mode enabled*/

#if defined(RF_STANDBY)/*if spirit1 is in standby*/

  if(EXTI->PR & KEY_BUTTON_EXTI_LINE)
  {
    HAL_GPIO_EXTI_Callback(KEY_BUTTON_EXTI_LINE);
    /* EXTI line 13 interrupt detected */
    if(HAL_GPIO_ReadPin(KEY_BUTTON_GPIO_PORT, KEY_BUTTON_PIN) == 0x01) //0x00
    {
      HAL_GPIO_EXTI_Callback(KEY_BUTTON_EXTI_LINE);

      PushButtonStatusWakeup = SET;
      PushButtonStatusData = RESET;
      wakeupCounter = LPM_WAKEUP_TIME;
      dataSendCounter = DATA_SEND_TIME;
      dataSendCounter++;
    }
    __HAL_GPIO_EXTI_CLEAR_IT(KEY_BUTTON_EXTI_LINE);
  }
#else /*if spirit1 is not in standby or sleep mode but MCU is in LPM*/

  if(__HAL_GPIO_EXTI_GET_IT(KEY_BUTTON_EXTI_LINE) != RESET)
  {
    __HAL_GPIO_EXTI_CLEAR_IT(KEY_BUTTON_EXTI_LINE);

    HAL_GPIO_EXTI_Callback(KEY_BUTTON_EXTI_LINE);

    Set_KeyStatus(SET);
  }
#endif
#endif
}
Esempio n. 24
0
void prvExtCtrlHandler(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
{
    GPIO_PinState xPinState = HAL_GPIO_ReadPin(GPIOx, GPIO_Pin);

    switch(xPinState)
    {
        case GPIO_PIN_SET:
            /* Rising edge */
            if(GPIO_Pin == GPIO_PIN_0)
                xPitchTickTmp = __HAL_TIM_GetCounter(&xTimeBaseHandle);
            else if(GPIO_Pin == GPIO_PIN_1)
                xRollTickTmp = __HAL_TIM_GetCounter(&xTimeBaseHandle);
            else if(GPIO_Pin == GPIO_PIN_3)
                xYawTickTmp = __HAL_TIM_GetCounter(&xTimeBaseHandle);
            break;
        case GPIO_PIN_RESET:
            /* Falling edge */
            if(GPIO_Pin == GPIO_PIN_0)
                xPitchTick = __HAL_TIM_GetCounter(&xTimeBaseHandle) - xPitchTickTmp;
            else if(GPIO_Pin == GPIO_PIN_1)
                xRollTick = __HAL_TIM_GetCounter(&xTimeBaseHandle) - xRollTickTmp;
            else if(GPIO_Pin == GPIO_PIN_3)
                xYawTick = __HAL_TIM_GetCounter(&xTimeBaseHandle) - xYawTickTmp;
            break;
        default:
            break;
    }
    __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
}
Esempio n. 25
0
uint8_t frsky_d8_rx_getpkt(void)
{
  uint8_t ret = 0;
  if (HAL_GPIO_ReadPin(CC2500_GD0_GPIO, CC2500_GD0_PIN) == GPIO_PIN_SET)
  {
    // note: can't read this while the packet is still being received.
    // HAL_Delay(1); // but this is just silly.
    CC2500_Strobe(CC2500_STROBE_SIDLE);
    
    volatile uint8_t rx_packet_length = CC2500_ReadReg(CC2500_REG_RXBYTES | CC2500_READ_BURST);
    
    if ((rx_packet_length > 7) && (rx_packet_length < D8_MAX_PACKET_SIZE)) // TODO: fix this to detect pktlen from bindmode
    {
      CC2500_ReadRXData(rxmsg.packet, rx_packet_length);
      
      if ((rxmsg.d8_rx_packet_data.header_bindcode == m_config.frsky_d8_bind_info.bind_id) && (rxmsg.d8_rx_packet_data.len == 0x11))
        /* So, there's two bytes in the packet header that indicate something.
         * 0x0100 - North American launch day taranis A
         *        - DJT jr module
         * 0x0300 - XJT jr module
         * There are others out there which are unknown, so this check is removed for now.
         * Also, there's a CRC or something at the end. But it isn't. 0xA0 bits will always match it. */
        ret = rx_packet_length;
    }
    CC2500_Strobe(CC2500_STROBE_SFRX);
  }
  
  return ret;
}
Esempio n. 26
0
int HAL_UART_Slave_Enabled()
{
#ifdef DISABLE_EXTERNAL_UART_INTERFACE
	return 0;
#endif
	return (HAL_GPIO_ReadPin(GPIOB,GPIO_PIN_15) != GPIO_PIN_SET);
}
Esempio n. 27
0
uint8_t processUserInput(int8_t opt) {
  char msg[30];

  if(!(opt >=1 && opt <= 3))
    return 0;

  sprintf(msg, "%d", opt);
  UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg));

  switch(opt) {
  case 1:
    HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
    break;
  case 2:
    sprintf(msg, "\r\nUSER BUTTON status: %s",
        HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13) == GPIO_PIN_RESET ? "PRESSED" : "RELEASED");
    UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg));
    break;
  case 3:
    return 2;
  };

  UART_Transmit(&huart2, (uint8_t*)PROMPT, strlen(PROMPT));
  return 1;
}
void keypad_mode(void)
{
	osSemaphoreWait(keypad_semaphore, osWaitForever);
	switch (key_number){
		case 1:
			DISPLAY_TEMP=1;
			DISPLAY_ACC =0;
			ACC_PITCH = 1;
			ACC_ROLL = 0;
			break;
		case 2:
			DISPLAY_TEMP=0;
			DISPLAY_ACC =1;
			ACC_PITCH = 1;
			ACC_ROLL = 0;
			break;
		case 3:
			DISPLAY_TEMP=0;
			DISPLAY_ACC =1;
			ACC_PITCH = 0;
			ACC_ROLL = 1;
			break;
		default:
			break;
	}
	
	rows_init();
	if(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_5) == 0)
	{
			init_columns();
			if(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_13) == 0)		
			{
				key_number = 1;
			}
			else if(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_12) == 0)
			{
				key_number = 2;
			}
			else if(HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_11) == 0)
			{
				key_number = 3;
			}
			printf("%d\n", key_number);

		}  		

}
Esempio n. 29
0
int HAL_RN4020_Get_RTS()
{
#ifdef ENABLE_RN4020
    return (HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_1) == GPIO_PIN_SET);
#else
    return 0;
#endif
}
Esempio n. 30
0
int HAL_RN4020_Get_MLDP_EV()
{
#ifdef ENABLE_RN4020
    return (HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_15) == GPIO_PIN_SET);
#else
    return 0;
#endif
}