void main()
{
	xbee_fw_buffer_t fw;
	char buffer[80];
	unsigned long t;
	int i, result, last_state;

	xbee_dev_init( &my_xbee, &XBEE_SERPORT, xbee_awake_pin, xbee_reset_pin);

	// Use helper API for reading firmware from a buffer (or ximported file).
	xbee_fw_buffer_init( &fw, ximport_length( FIRMWARE),
																ximport_data( FIRMWARE));

	xbee_fw_install_init( &my_xbee, NULL, &fw.source);
	do
	{
		t = MS_TIMER;
		last_state = fw.source.state;
		result = xbee_fw_install_oem_tick( &fw.source);
		t = MS_TIMER - t;
		if (t > 50)
		{
			printf( "!!! tick blocked for %lums in state %u (now state %u)\n",
				t, last_state, fw.source.state);
		}
		// clear to end of line and print new status
		printf( "\x1B[K" " %ls\r", xbee_fw_status_oem( &fw.source, buffer));
	} while (result == 0);

	if (result == 1)
	{
		printf( "firmware update completed successfully\n");
		configure_modem( &my_xbee);
	}
	else
	{
		printf( "firmware update failed with error %d\n", result);
		i = xbee_ser_read( &my_xbee.serport, buffer, 80);
		if (i > 0)
		{
			printf( "extra bytes in buffer: [%.*s]\n", i, buffer);
		}
	}

	xbee_ser_close( &my_xbee.serport);
}
Beispiel #2
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_DAC_Init();
  MX_TIM2_Init();
  MX_TIM3_Init();

  /* USER CODE BEGIN 2 */
  configure_modem();
  acquisition_init();
  acquisition_start();
  /* USER CODE END 2 */

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

  /* USER CODE BEGIN 3 */

  }
  /* USER CODE END 3 */

}