Beispiel #1
0
static void sim900_put_string(const char * const sz,const uint8_t isPGM)
{
	
//	debug_string(NORMAL,PSTR("(sim900_put_string) IN\r\n"),true);

	const char * p = sz;


	if(isPGM) {
		while(1) {
			const char c = nvm_flash_read_byte((flash_addr_t)p++);
			if(0==c) break;
			while (usart_data_register_is_empty(USART_GPRS) == false) {}
			usart_put(USART_GPRS, c);
			if(g_log_verbosity>NORMAL) usart_putchar(USART_DEBUG,c);
		}
		} else {
		while(1) {
			const char c = *p++;
			if(0==c) break;
			while (usart_data_register_is_empty(USART_GPRS) == false) {}
			usart_put(USART_GPRS, c);
			if(g_log_verbosity>NORMAL) usart_putchar(USART_DEBUG,c);
		}
	}

//	debug_string(NORMAL,PSTR("(sim900_put_string) OUT\r\n"),true);
		
}
Beispiel #2
0
void debug_string(uint8_t level,const char * const sz,const uint8_t isPGM)
{
	if(level>g_log_verbosity) return;

	const char * p = sz;

	if(isPGM) {
		nvm_wait_until_ready();
		while(1) {
			const uint8_t c = nvm_flash_read_byte( p++ );
			if(c==0) break;
//			while (udi_cdc_is_tx_ready()) {}
//			udi_cdc_putc(c);
			while (usart_data_register_is_empty(USART_DEBUG) == false) {}
			usart_put(USART_DEBUG, c);
		}
		
	} else {
		while(*p) {
			while (usart_data_register_is_empty(USART_DEBUG) == false) {}
			usart_put(USART_DEBUG, *p++);
			//while (udi_cdc_is_tx_ready()) {}
			//udi_cdc_putc(*p++);

		}
	}
}
Beispiel #3
0
/**
 * \brief Test checking different registers of the USART module
 *
 * This function calls the different check functions and make sure they set the
 * correct values.
 *
 * \param test Current test case.
 */
static void run_check_registers_test(const struct test_case *test)
{
	bool success;
	uint8_t data = 'b';

	
	const usart_rs232_options_t options = {
		.baudrate   = CONF_UNIT_BAUDRATE,
		.charlength = CONF_UNIT_CHARLENGTH,
		.paritytype = CONF_UNIT_PARITY,
		.stopbits   = CONF_UNIT_STOPBITS
	};

	usart_init_rs232(&CONF_UNIT_USART, &options);
      
	/* Test empty data register */
	success = usart_data_register_is_empty(&CONF_UNIT_USART);
	test_assert_true(test, success,
			"Checking if the data register is empty failed");
	
	/* Test finished data transfers */
	usart_put(&CONF_UNIT_USART, data);
	for(volatile uint16_t delay=0;delay<20000;delay++);
    
	success = usart_rx_is_complete(&CONF_UNIT_USART);
	usart_get(&CONF_UNIT_USART);
	test_assert_true(test, success,
   	                "Checking if the receive is finished failed");		       
					
	success = usart_tx_is_complete(&CONF_UNIT_USART);
	test_assert_true(test, success,
	                "Checking if the transmit is finished failed");

}
Beispiel #4
0
/**
 * \brief Send a data with the USART module
 *
 * This function outputs a data using the USART module.
 *
 * \param usart The USART module.
 * \param c The data to send.
 *
 * \return STATUS_OK
 */
enum status_code usart_putchar(USART_t *usart, uint8_t c)
{
	while (usart_data_register_is_empty(usart) == false) {
	}
	
	(usart)->DATA = c;
	return STATUS_OK;
}
Beispiel #5
0
/**
 * \brief Send a data with the USART module
 *
 * This function outputs a data using the USART module.
 *
 * \param usart The USART module.
 * \param c The data to send.
 *
 * \return STATUS_OK
 */
status_code_t usart_putchar(USART_t *usart, uint8_t c)
{
	while (usart_data_register_is_empty(usart) == false) {
	}

	usart->UDR = c;
	return STATUS_OK;
}
Beispiel #6
0
int ext_ser_putchar(char c, FILE *stream)
{

	if (c == '\n')
	ext_ser_putchar('\r', stream);
	while(!usart_data_register_is_empty(EXT_USART_SERIAL));
	usart_putchar(EXT_USART_SERIAL, c);
	return 0;
}
Beispiel #7
0
int ntx2b_ser_putchar(char c, FILE *stream)
{

	if (c == '\n')
	ntx2b_ser_putchar('\r', stream);
	while(!usart_data_register_is_empty(NTX2B_USART_SERIAL));
	usart_putchar(NTX2B_USART_SERIAL, c);
	return 0;
}
/**
 * \internal
 * \brief Helper function to send a byte over an arbitrary interface
 *
 * This function is used to hide what interface is used by the component
 * driver, e.g.  the component driver does not need to know if USART in SPI
 * mode is used or the native SPI module.
 *
 * \param data The byte to be transfered
 */
__always_inline static void ili9341_send_byte(uint8_t data)
{
#if defined(CONF_ILI9341_USART_SPI)
#  if XMEGA
	while (!usart_data_register_is_empty(CONF_ILI9341_USART_SPI)) {
		/* Do nothing */
	}

	irqflags_t flags = cpu_irq_save();
	usart_clear_tx_complete(CONF_ILI9341_USART_SPI);
	usart_put(CONF_ILI9341_USART_SPI, data);
	cpu_irq_restore(flags);
#  else
	usart_spi_write_single(CONF_ILI9341_USART_SPI, data);
#  endif
#elif defined(CONF_ILI9341_SPI)
	/* Wait for any previously running send data */
	ili9341_wait_for_send_done();

	spi_write_single(CONF_ILI9341_SPI, data);
#endif
}