Beispiel #1
0
static void configure_modem()
{
  HAL_StatusTypeDef res;

  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_12, LED_OFF);
  MX_USART1_UART_Init(9600);

  res = HAL_UART_Transmit(&huart1, at_mode_cmd, sizeof(at_mode_cmd)-1, HAL_MAX_DELAY);
  assert(res != HAL_OK);

  HAL_Delay(1500);

  res = HAL_UART_Transmit(&huart1, at_rate_cmd, sizeof(at_rate_cmd)-1, HAL_MAX_DELAY);
  assert(res != HAL_OK);

  HAL_Delay(1500);

  MX_USART1_UART_Init(115200);

  res = HAL_UART_Transmit(&huart1, at_reset_cmd, sizeof(at_reset_cmd)-1, HAL_MAX_DELAY);
  assert(res != HAL_OK);

  HAL_Delay(1500);

  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_12, LED_ON);
}
Beispiel #2
0
int main(void)
{

  HAL_Init();
  SystemClock_Config();

  MX_GPIO_Init();
  MX_CAN_Init();
  MX_I2C1_Init();
  MX_USART3_UART_Init();
  MX_USART2_UART_Init();
  MX_USART1_UART_Init();
  MX_TIM1_Init();
  USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS);
  USBD_RegisterClass(&hUsbDeviceFS, &USBD_CUSTOM_HID);
  USBD_CUSTOM_HID_RegisterInterface(&hUsbDeviceFS, &USBD_CustomHID_fops_FS);
  USBD_Start(&hUsbDeviceFS);

  while (1)
  {

  /* USER CODE END WHILE */


  /* USER CODE BEGIN 3 */
	  HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_1);
	  HAL_Delay(blinkingDelay);
  }
  /* USER CODE END 3 */

}
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_USART1_UART_Init();
SPI1_Initialize();
  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}
Beispiel #4
0
int main(void)
{

  /* USER CODE BEGIN 1 */
	uint8_t damogranlabs_logo[]={
		0x0F,
		0x13,
		0x11,
		0x11,
		0x0e,
		0x00,
		0x00		
	};
  /* 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_USART1_UART_Init();

  /* USER CODE BEGIN 2 */
	LCD_Init(2, 20);
	LCD_CreateChar(0, damogranlabs_logo); 
	
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
	LCD_PrintString(2, 1, "n: ");
	LCD_PrintNumber(2, 4, -10);
	
	LCD_PrintString(2, 10, "f: ");
	LCD_PrintFloat(2, 13, -326.5635, 5);
	
	while (1)
  {
		LCD_PrintStringWindow(1, 3, 14, 350, "Find us on github and www.damogranlabs.com");
		LCD_Clear();
		LCD_PrintString(1, 1, "www.damogranlabs.com");
		LCD_PutCustom(2, 10, 0);
		LCD_ClearArea(1, 5, 12); 
		HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);
		HAL_Delay(2000);
		
		
		
				/* USER CODE END WHILE */

		/* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */

}
Beispiel #5
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_I2C1_Init();
  MX_TIM16_Init();
  MX_USART1_UART_Init();
  /* USER CODE BEGIN 2 */
  SET_BIT(USART1->CR1, USART_CR1_RXNEIE);
  sensact::cOneWireApplication testApp;
  sensact::cOneWire::Start(&testApp);
  testApp.Run(&hi2c1);
  return 0;
}
Beispiel #6
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_USART1_UART_Init();

  /* USER CODE BEGIN 2 */
	LCD_Init(2, 20);
	LCD_PrintString(0, 0, "Damogran Labs");
	
	Encoder_Init(&encoder1, ENC1_A_GPIO_Port, ENC1_A_Pin, ENC1_B_GPIO_Port, ENC1_B_Pin);
	Encoder_Init(&encoder2, ENC2_A_GPIO_Port, ENC2_A_Pin, ENC2_B_GPIO_Port, ENC2_B_Pin);
		
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
	LCD_PrintNumber(1, 0, encoder1.abs_rot);
	LCD_PrintNumber(1, 6, encoder2.abs_rot);
	
  while (1)
  {
		if(Encoder_GetState(&encoder1)){
			LCD_PrintString(1, 0, "     ");
			LCD_PrintNumber(1, 0, encoder1.abs_rot);
		}	
		if(Encoder_GetState(&encoder2)){
			LCD_PrintString(1, 6, "     ");
			LCD_PrintNumber(1, 6, encoder2.abs_rot);
		}	
		
		if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) == GPIO_PIN_SET){
			Encoder_SetAbsToZero(&encoder1);
			Encoder_SetAbsToZero(&encoder2);
		}
		
		HAL_Delay(100);
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}
Beispiel #7
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_ADC_Init();
  MX_USART1_UART_Init();

  /* USER CODE BEGIN 2 */
  char ch;
  ch = 'x';
  HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 100);

  sprintf(strbuf,"Hello\n");

  uint32_t adcvals[5];
  HAL_ADC_Start(&hadc);

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
  	HAL_ADC_Start(&hadc);
	for (int i=0;i<3;i++){
		while(HAL_IS_BIT_CLR(hadc.Instance->ISR, (ADC_FLAG_EOC|ADC_FLAG_EOS))){}
		adcvals[i] = hadc.Instance->DR;
	}
	for (int i=0;i<5;i++){
		sprintf(strbuf,"i:%d,adc:%4d	",i,adcvals[i]);
		HAL_UART_Transmit(&huart1,strbuf,strlen(strbuf),1000);
	}
	
	sprintf(strbuf,"\n");
	HAL_UART_Transmit(&huart1,strbuf,strlen(strbuf),1000);
	HAL_Delay(1000);


  }
  /* USER CODE END 3 */

}
Beispiel #8
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_DMA_Init();
	MX_I2C3_Init();
	MX_TIM1_Init();
	MX_TIM2_Init();
	MX_TIM3_Init();
	MX_TIM4_Init();
	MX_TIM5_Init();
	MX_USART1_UART_Init();
	MX_USART2_UART_Init();
	MX_TIM11_Init();

	/* USER CODE BEGIN 2 */
	HAL_TIM_Base_Start_IT(&htim11); // 100 msec timer
	initSonar( MAX_SONAR);
	initSerOutput();
	/* USER CODE END 2 */

	/* Infinite loop */
	/* USER CODE BEGIN WHILE */
	while (1)
	{
		/* USER CODE END WHILE */

		/* USER CODE BEGIN 3 */
		// >>>>> Sonar reading
		triggerSonar( COUPLE_0_2);
		HAL_Delay(49);
		triggerSonar( COUPLE_1_3);
		HAL_Delay(49);
		// <<<<< Sonar reading

		// >>>>> Serial Output
		convertMeasures();
		sendMeasures();
		// <<<<< Serial Output

	}
	/* USER CODE END 3 */

}
Beispiel #9
0
int main(void)
{

  /* USER CODE BEGIN 1 */
  /* USER CODE END 1 */
	Task_Info_t TaskState=TASK_INFO_INIT;
  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* Configure the system clock */
  SystemClock_Config();

  /* System interrupt init*/
  /* Sets the priority grouping field */
  HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0);
  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

  /* Initialize all configured peripherals */
    MX_GPIO_Init();
  MX_DMA_Init();
  MX_USART6_UART_Init();
  MX_USART1_UART_Init();
  MX_USART2_UART_Init();
  MX_USART3_UART_Init();
  MX_TimerDynamixel_Init(&TimHandle2 , TIM2);
  MX_TimerDynamixel_Init(&TimHandle3 , TIM3);
  MX_TimerDynamixel_Init(&TimHandle4 , TIM4);

  Trace_Init();
  HAL_Delay(1000);
  Trace_Raw("Medula control board start...\n\r");
  Dynamixel_Init();
  IO_Data_init();
  while (0)
  {
	  Dynamixel_test(&TaskState);
	  Trace_Task();

  }
  while (1)
  {
	  HAL_Delay(10);
	  IO_Data_Scan_In();
	  Appli(&TaskState);
	  Trace_Task();
	  HAL_Delay(5);
	  IO_Data_Scan_Out();

  }
  /* USER CODE END 3 */

}
Beispiel #10
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_ADC1_Init();
  MX_CAN1_Init();
  MX_CAN2_Init();
  MX_I2C2_Init();
  MX_IWDG_Init();
  MX_SPI2_Init();
  MX_SPI3_Init();
  MX_TIM1_Init();
  MX_USART1_UART_Init();
  MX_USART6_UART_Init();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Call init function for freertos objects (in freertos.c) */
  MX_FREERTOS_Init();

  /* Start scheduler */
  osKernelStart();
  
  /* We should never get here as control is now taken by the scheduler */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}
Beispiel #11
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_COMP1_Init();
  MX_COMP2_Init();
  MX_I2C1_Init();
  MX_TIM3_Init();
  MX_USART1_UART_Init();
	MX_ADC_Init();
	MX_DMA_Init();

  /* USER CODE BEGIN 2 */
  init_all();
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
		period_time_check_flags();
//		if (HAL_GPIO_ReadPin(GPIOB, GPIO_PIN_4) != GPIO_PIN_RESET)
//		{
//			HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_10);
//			buzzer(beeps,1);
//			buzzer_speed(100);
//		}
		
		
		
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
		speed_counter++;
  }
  /* USER CODE END 3 */

}
Beispiel #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_DMA_Init();
  MX_SPI1_Init();
  MX_TIM2_Init();
  MX_TIM3_Init();
  MX_TIM7_Init();
  MX_TIM10_Init();
  MX_TIM11_Init();
  MX_TIM13_Init();
  MX_TIM14_Init();
  MX_USART1_UART_Init();
  MX_USART2_UART_Init();

  /* USER CODE BEGIN 2 */
	
	HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1);      //Motor1
	HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4);      //Motor2
	HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);      //Motor3
	HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4);      //Motor4

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}
Beispiel #13
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_USART1_UART_Init();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    uint8_t i;
    uint8_t flag = 0;
    number_of_devices = 1;
    OW_Scan(id_buffer, number_of_devices);
    OW_Send(OW_SEND_RESET, (uint8_t *)"\xcc\x44", 2, 0, 0, OW_NO_READ);
    HAL_Delay(700);
    for (i = 0; i < number_of_devices; i++)
    {
      OW_Massage(flag);
      OW_Send(OW_SEND_RESET, massage_buffer, 12, temperature_buffer, 2, 10);
      OW_Output();
      flag++;
    }
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}
Beispiel #14
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_DMA_Init();
  MX_ADC1_Init();
  MX_ADC2_Init();
  MX_TIM1_Init();
  MX_TIM2_Init();
  MX_USART1_UART_Init();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  HAL_TIM_Base_Start_IT(&htim1);
  HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_1);
  HAL_TIMEx_PWMN_Start(&htim1,TIM_CHANNEL_1);
  HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_2);
  HAL_TIMEx_PWMN_Start(&htim1,TIM_CHANNEL_2);
  HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_3);
  HAL_TIMEx_PWMN_Start(&htim1,TIM_CHANNEL_3);
  HAL_TIM_Base_Start_IT(&htim2);
  while (1)
  {
  /* USER CODE END WHILE */
  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}
Beispiel #15
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_DMA_Init();
  MX_CRC_Init();
  MX_USART1_UART_Init();
//  MX_RTC_Init();  /**< 重新用cube生成工程时 注释掉此函数 再下载 */

  /* USER CODE BEGIN 2 */
    rtc_init();     /**< 使用改造后的初始化函数实现备份掉电时的数据 */
    
    GUI_Init();
    GUI_UC_SetEncodeUTF8();
    GUI_SetFont(&GUI_Font24B_1);
    GUI_SetBkColor(GUI_BLACK);
    GUI_SetColor(GUI_GREEN);

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
    RTC_display_current_time(20, 170);
    RTC_display_current_date(120, 170);  
  }
  /* USER CODE END 3 */

}
Beispiel #16
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* MCU configure */
  SCB->VTOR = FLASH_BASE | 0x20000;
  
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();
	
  /* Configure the system clock to 168 MHz */
  SystemClock_Config();
  
  /* Convert version string */
  uint32_t len =0;
  len += sprintf(&version[len],"%s ",FIRMWARE_NAME);
  len += sprintf(&version[len],"%s ",FIRMWARE_VERSION);
  len += sprintf(&version[len],"%s ",FIRMWARE_TIME);
  version[len]=0;
  
  /* Init USART1 for debug */
  MX_USART1_UART_Init();
  printf("%s\n",version);
  
  /* Configure */
	itouch_init();
	
  /* Init MSC Application */
  USBD_Init(&USBD_Device, &MSC_Desc, 0);
  
  /* Add Supported Class */
  USBD_RegisterClass(&USBD_Device, USBD_MSC_CLASS);
  
  /* Start Device Process */
  USBD_Start(&USBD_Device);

  /* Run Application (Interrupt mode) */
  while (1)
  {
    itouch_run();
  }
}
Beispiel #17
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_TIM2_Init();
  MX_USART2_UART_Init();
  MX_USART6_UART_Init();
  MX_USART1_UART_Init();

  /* USER CODE BEGIN 2 */
	HAL_TIM_Base_Start_IT(&htim2);

#ifdef DEBUG_TO_CONSOLE
	initialise_monitor_handles();
	printf("start\n");
#endif
	UARTInit();

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
	while (1) {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
		UARTLoopDemo();
	}
  /* USER CODE END 3 */

}
Beispiel #18
0
int main(void)
{

  /* USER CODE BEGIN 1 */
  uint32_t i;
  /* 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_I2C1_Init();
  MX_RTC_Init();
  MX_USART1_UART_Init();

  /* USER CODE BEGIN 2 */
  for(i=0; i<ARRAY_SIZE; i++){
    write_data[i] = i;
  }
  
  // Write some data to the selected address
  FRAM_MultiByte_Write(&hi2c1, 0x10000, &write_data[0], ARRAY_SIZE);
  
  // Read the data from the selected address
  FRAM_MultiByte_Selective_Read(&hi2c1, 0x10000, &read_data[0], ARRAY_SIZE);
  
  /* USER CODE END 2 */

  /* USER CODE BEGIN 3 */
  /* Infinite loop */
  while (1)
  {

  }
  /* USER CODE END 3 */

}
Beispiel #19
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_RTC_Init();
  MX_SPI2_Init();
  MX_SPI4_Init();
  MX_USART1_UART_Init();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* USER CODE BEGIN 3 */
  /* Infinite loop */
	
	//set low level to ground
	HAL_GPIO_WritePin(GPIOC,GPIO_PIN_1 | GPIO_PIN_3, GPIO_PIN_SET);
	
	uint8_t string[] = "Hello world!\n";
	
  while (1)
  {
		HAL_UART_Transmit(&huart1, string, 12, 100);
		HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_1 | GPIO_PIN_5);
		for (int i = 0; i < 5000000; i++);
  }
  /* USER CODE END 3 */

}
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_USART1_UART_Init();
	MX_SPI1_Init();
	MX_TIM1_Init();
	MX_TIM3_Init();

	HAL_TIM_Base_Start(&htim1);

	static char buf[50];


	NRF24L01_Reset();
	NRF24L01_Initialize();
	HAL_Delay(150);


	CX10_init();
	HAL_Delay(50);
	CX10_bind();

	while (1) {
		process_CX10();
		HAL_Delay(6);
	}

}
Beispiel #21
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_RTC_Init();
  //if(!(*(volatile uint32_t *) (BDCR_RTCEN_BB)))__HAL_RCC_RTC_ENABLE();
  MX_TIM2_Init();
  MX_TIM3_Init();
  MX_USART1_UART_Init();
  MX_USART2_UART_Init();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
    HAL_RTC_GetTime(&hrtc, &myTime, FORMAT_BIN);
    HAL_RTC_GetDate(&hrtc, &myDate, FORMAT_BIN);
  }
  /* USER CODE END 3 */

}
Beispiel #22
0
void board_init() {
    /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
    HAL_Init();

    /* Configure the system clock */
    SystemClock_Config();

    MX_GPIO_Init();

#if ENABLE_UART
    MX_USART1_UART_Init();
    uart_printf("\r\n\r\nUART online!\r\n");
#endif

    MX_ADC_Init();

    MX_I2C1_Init();

    uart_printf("board_init done\r\n");

}
Beispiel #23
0
int main(void)
{



  /* 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_DMA_Init();
  MX_ADC1_Init();
  MX_I2C1_Init();
  MX_TIM10_Init();
  MX_TIM11_Init();
  MX_USART1_UART_Init();

  xTaskCreate(task_safety, "Safety", 350, NULL, 1, NULL);
  xTaskCreate(task_master, "Master", 350, NULL, 1, NULL);
  xTaskCreate(task_control, "Control", 1000, NULL, 3, NULL);
  xTaskCreate(task_test, "Test", 500, NULL, 4, NULL);

  update_coefficients_QUEUE = xQueueCreate(3, sizeof(uint8_t));
  control_sig_QUEUE = xQueueCreate(3, sizeof(int16_t));;
  vSemaphoreCreateBinary(testing_SEMAPHORE);
  vSemaphoreCreateBinary(data_SEMAPHORE);
  osKernelStart();
  
  /* We should never get here as control is now taken by the scheduler */
  /* Infinite loop */
  while (1)
  {

  }

}
Beispiel #24
0
void HAL_RTC_AlarmAEventCallback(RTC_HandleTypeDef *hrtcc)
{

		//HAL_GPIO_TogglePin(Kimenet_GPIO_Port,Kimenet_Pin);
	   MX_USART1_UART_Init();
	PutString("--------\n");	
	
	
				HAL_RTC_GetTime(&hrtc,&sTim,RTC_FORMAT_BIN); 
		  HAL_RTC_GetDate(&hrtc, &sDat, RTC_FORMAT_BIN);
		
		PutNumber((uint32_t)sTim.Hours);
		
		PutString(":");
		PutNumber((uint32_t)sTim.Minutes);
	
		PutString(":");
		PutNumber((uint32_t)sTim.Seconds);
			PutString("\n");
			PutString("--------\n");	

}
Beispiel #25
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_CAN_Init();
  MX_USART1_UART_Init();

  /* USER CODE BEGIN 2 */
  setup_can_filter();

  for (int i = 0; i < 10; ++i)
  {
	  led_blink();
	  HAL_Delay(100);
  }

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  CanRxMsgTypeDef rx_msg;
  uint8_t prebuf[12];
  uint8_t uart_msg[18];

  while (1)
  {
	  //

	  while (__HAL_CAN_MSG_PENDING(&hcan, CAN_FIFO0) <= 0) ;

	  hcan.pRxMsg = &rx_msg;
	  if (HAL_OK != HAL_CAN_Receive(&hcan, CAN_FIFO0, 3))
		  continue;

	  //

	  uint8_t flags = rx_msg.DLC & 0xf;

	  if (rx_msg.RTR == CAN_RTR_REMOTE)
		  flags |= 0x10;

	  if (rx_msg.IDE == CAN_ID_EXT)
		  flags |= 0x20;

	  uint32_t id = (rx_msg.IDE == CAN_ID_EXT ? rx_msg.ExtId : rx_msg.StdId);

	  for (int i = 3; i >= 0; --i)
	  {
		  prebuf[i] = (id & 0xff);
		  id >>= 8;
	  }

	  for (int i = 4; i < 12; ++i)
		  prebuf[i] = 0;

	  for (int i = 0; i < 8 && i < rx_msg.DLC; ++i)
		  prebuf[4+i] = rx_msg.Data[i];

	  //

	  int j = 0;
	  for (int i = 0; i < 12; i += 3, j += 4)
	  {
		  uint32_t triple = 0;
		  for (int k = 0; k < 3; ++k)
		  {
			  triple <<= 8;
			  triple += prebuf[i+k];
		  }

		  for (int k = 0; k < 4; ++k)
		  {
			  uart_msg[j+3-k] = basis_64[triple & 63];
			  triple >>= 6;
		  }

	  }

	  uart_msg[16] = basis_64[flags];
	  uart_msg[17] = '\n';

	  //

	  HAL_UART_Transmit(&huart1, uart_msg, 18, 1000);

	  //

	  led_blink();

  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}
Beispiel #26
0
int main(void)
{
int i=5000;
	
uint8_t ultrasoundEnableFlag;
 uint16_t voltage; 
	/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
  /* Configure the system clock */
  SystemClock_Config_8MHz();
  //__HAL_RCC_PWR_CLK_ENABLE();
  /* Initialize all configured peripherals */
	
	MX_GPIO_Init();
			HAL_GPIO_WritePin( DCDC_EN_GPIO_Port , DCDC_EN_Pin , 0);								//
			HAL_GPIO_WritePin( DCDC_PWR_GPIO_Port , DCDC_PWR_Pin , 0 );									//open drain kimenet,pch fet,
  MX_ADC_Init();
  //MX_I2C1_Init(); 
	 //MX_TIM3_Init();
	 MX_USART1_UART_Init();

		GPIO_TIM3_OFF();
	//HAL_Delay(100);
		 MX_RTC_Init(); 
 /* Enable Power Clock */
  //__HAL_RCC_PWR_CLK_ENABLE();
	
		 uartTester();
		//	GPIO_TIM3_OFF();
		

//Feszültseg ellenörzése,sippogás-----------------------------------------------------
voltage=voltage_read(ADC_CHANNEL_2,2);
if(Full<voltage)
	batteryLevel=3;

if(Medium < voltage && voltage<= Full)
	batteryLevel=2;

if(Medium >= voltage)
	batteryLevel=1;

HAL_Delay(1000);
beeps(batteryLevel,1);
PutString("Software version 2016.07.26.\n");
PutString("batteryLevel: ");
			PutNumber(batteryLevel);
			PutString("\n");

while(1){
	//Feszültseg ellenörzése, paraméterek beállítása,fesz fvében------------------------
	voltage=voltage_read(ADC_CHANNEL_2,2);
	if(Low > voltage){
			if(UltraLow > voltage){
				voltage=voltage_read(ADC_CHANNEL_2,2);
				if(UltraLow > voltage){
					HAL_GPIO_WritePin( DCDC_PWR_GPIO_Port , DCDC_PWR_Pin , 1 );									//open drain kimenet,pch fet,
				HAL_PWR_EnterSTANDBYMode();
				}
			}
			ultrasoundEnableFlag=0;
			sleepNum=LowVoltSleep;
	}else{
			ultrasoundEnableFlag=1;
			sleepNum= linear(sleepNumMax,sleepNumMin, voltageMin,voltageMax,voltage);											
			soundNum=	linear(soundNumMin,soundNumMax,voltageMin,voltageMax,voltage);
			sounDelay=sDelay;
	}
			PutString("sleepNum");
			PutNumber(sleepNum);
			PutString("\n");
				PutString("soundNum");
			PutNumber(soundNum);
			PutString("\n");
	
	//Ultrahang generálás---------------------------------------------------------------
	
	if(ultrasoundEnableFlag){
		
		PutString("ultrasound(1)\n ");
			ultrasound(1);		
		
	}

	//Sleep-----------------------------------------------------------------------------
		
		//	HAL_ADC_MspDeInit(&hadc);
	HAL_Delay(10);
PutString("sleep!\n");


	
	HAL_NVIC_SetPriority(RTC_IRQn, 0, 0);
				HAL_NVIC_EnableIRQ(RTC_IRQn);
	

	
	for(uint8_t e=0 ; e < sleepNum ; e++){

			
			HAL_RTC_GetTime(&hrtc,&sTim,RTC_FORMAT_BIN); 
		  HAL_RTC_GetDate(&hrtc, &sDat, RTC_FORMAT_BIN);
		
		HAL_RTC_GetTime(&hrtc,&sTim,RTC_FORMAT_BIN); 
		  HAL_RTC_GetDate(&hrtc, &sDat, RTC_FORMAT_BIN);

		PutNumber((uint32_t)sTim.Hours);
		
		PutString(":");
		PutNumber((uint32_t)sTim.Minutes);
	
		PutString(":");
		PutNumber((uint32_t)sTim.Seconds);
			PutString("\n");
		
				if(sTim.Minutes==59){
						sAlarm.AlarmTime.Minutes=0;
					if(sTim.Hours==23){
							sAlarm.AlarmTime.Hours=0;
						}else{
							sAlarm.AlarmTime.Hours=sTim.Hours+1;
						}
					}else{
						sAlarm.AlarmTime.Minutes=sTim.Minutes+1;
						sAlarm.AlarmTime.Hours=sTim.Hours;
					}
					HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, FORMAT_BIN);		

				
					PutString("alarm: ");
		PutNumber((uint32_t)sAlarm.AlarmTime.Hours);		
		PutString(":");
		PutNumber((uint32_t)sAlarm.AlarmTime.Minutes);
							PutString(":");
		PutNumber((uint32_t)sAlarm.AlarmTime.Seconds);
		PutString("\n");
					
		SleepMode();
	}
					HAL_NVIC_DisableIRQ(RTC_IRQn);

	
	}			

}
Beispiel #27
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_CAN_Init();
  MX_IWDG_Init();
  MX_USART1_UART_Init();
  MX_USART2_UART_Init();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */

  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */

  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */

  /* Create the thread(s) */
  /* definition and creation of defaultTask */
  osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
  defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);

  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */

  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */
 

  /* Start scheduler */
  osKernelStart();
  
  /* We should never get here as control is now taken by the scheduler */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}
Beispiel #28
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();

  char is_joint = 1;

  if(is_joint)
  {
	  // init multiplexer pins
	  MX_SPI1_Init();
  }
  else
  {
	  MPX_UART_Init();
  }

  MX_USART1_UART_Init();
  MX_USART2_UART_Init();

  /* USER CODE BEGIN 2 */
  LED_init();

  if(is_joint)
  {
	  // set spi chip select high
	  HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET);

	  //init_2D(hspi1, GPIOB, GPIO_PIN_1);
	  init_1D();
  }
  else
  {
	  // set spi chip select high
	  MPX_UART_ONOFF(1);
  }

  huart_T = &huart2;
  huart_U = &huart1;

  float alpha, beta, delta;

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */

  USART_RX_FINISHED=0;
  USART_TX_FINISHED=1;

//  if(HAL_UART_Receive_IT(huart_U, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)
//  {
//	  char error = 1;
//  }

  int i = 0;

  //MPX_UART_Open(3);

  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

	if(is_joint & USART_TX_FINISHED)
	{
		get_2D(hspi1, GPIOB, GPIO_PIN_1, &alpha, &beta);
		get_1D(hspi1, GPIOA, GPIO_PIN_4, &delta);

		length = snprintf(usart_buffer, 128, "%f : %f : %f\r\n", alpha, beta, delta);

		USART_TX_FINISHED = 0;
		HAL_UART_Transmit(huart_T, usart_buffer, length, 20);
	}
	else
	{
		//length = snprintf(usart_buffer, 128, "hello");
		//MPX_UART_Transmit(huart_T, i%5, usart_buffer, length, 20);

		//HAL_Delay(200);

		//length = snprintf(usart_buffer, 128, "hello\r\n", alpha, beta, delta);
		//HAL_UART_Transmit(huart_U, usart_buffer, length, 20);
	}

//
//	if(USART_RX_FINISHED==1)
//	{
//		if(aRxBuffer[0]=='r')
//		{
//			HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
//		}
//		else if(aRxBuffer[0]=='b')
//		{
//			HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_4);
//		}
//		/*else if(aRxBuffer[0]=='g')
//		{
//			HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_1);
//		}*/
//		else
//		{
//			//HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_1);
//			HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_4);
//			HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
//		}
//
//		HAL_UART_Transmit(huart_T, aRxBuffer, RXBUFFERSIZE, 20);
//
//		USART_RX_FINISHED=0;
//
//		if(HAL_UART_Receive_IT(huart_U, (uint8_t *)aRxBuffer, RXBUFFERSIZE) != HAL_OK)
//		{
//		  char error = 1;
//		}
//	}


	//HAL_UART_Transmit(&huart2, "ABC", 3, 20);

	i++;
  }
  /* USER CODE END 3 */

}
Beispiel #29
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_USART1_UART_Init();

  /* USER CODE BEGIN 2 */

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
		int count = 0;
		char temp[100];
		printf("STM32> ");
		HAL_Delay(200);
		count = uart_gets((uint8_t*)input, BUFFSIZE);	//read input
		//printf("Read %d chars:%s\r\n", count, input);
		char cmd[100];
		int addr,data,paramNum;
		sscanf(input, "%s", cmd);
		if(strcmp(cmd,"peek")==0){
			paramNum = sscanf(input,"%s %x %s",cmd,&addr,temp);
			if(paramNum==2){
				printf("peek: 0x%x in addr 0x%x\r\n",*(int*)addr,addr);
			}else{
				printf("Usage:peek addr\r\n");
			}
		}else if(strcmp(cmd,"poke")==0){
			paramNum = sscanf(input,"%s %x %x %s",cmd,&addr,&data,temp);
			if(paramNum==3){
				*((int*)addr) = data;
				printf("poke: change addr 0x%x to 0x%x\r\n",addr,data);
			}else{
				printf("Usage:poke addr data\r\n");
			}
		}else if(strcmp(cmd,"tempaddr")==0){
			printf("temp array's addr is 0x%x, length:%d\r\n",(int)temp,100);
		}else{
			printf("invalid cmd!\r\n");
		}
		
  }
  /* USER CODE END 3 */

}
Beispiel #30
-8
int main(void)
{

  /* USER CODE BEGIN 1 */
	char ADC_Tx_Data[70];
  /* 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_DMA_Init();
  MX_ADC1_Init();
  MX_USART1_UART_Init();

  /* USER CODE BEGIN 2 */
	
	HAL_UART_Receive_IT(&huart1, (uint8_t *)Rx_Data, 1);
	HAL_ADC_Start_DMA(&hadc1, (uint32_t*)&ADC_Value, 6);

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
		HAL_Delay(15);
		HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_4);
		HAL_Delay(15);
		HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_0);	
		HAL_Delay(15);
		HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_1);	
		HAL_Delay(15);
		HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_2);	
		HAL_Delay(15);		
	  sprintf(ADC_Tx_Data,"ADC1:%4d\tADC2:%4d\tADC3:%4d\tADC4:%4d\tADC5:%4d\tADC6:%4d\n\r", ADC_Value[0], ADC_Value[1], ADC_Value[2], ADC_Value[3], ADC_Value[4], ADC_Value[5]);
		HAL_UART_Transmit_IT(&huart1, (uint8_t *)ADC_Tx_Data, 70);
			
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}