Beispiel #1
0
Datei: uart.c Projekt: fser/rflpc
int _rflpc_uart_init(uart_pin_conf_t *uart)
{
   
  /* Set line control values (p. 306) */
  /* 8 data bits, no parity, 1 stopbit */
  /* 3 is for 8 data bits, 7 is to enable DLL and DLM registers (for selecting baud rate) */
  uart->base_address->LCR = (3 | (1 << 7));

  /* Set DLL=4, DLM=0 (p. 315) */
  uart->base_address->DLL = 4;
  uart->base_address->DLM = 0;

  /* Set DIVADDVAL = 5 and MULVAL = 8 (p. 315) */
  uart->base_address->FDR = 5 | (8 << 4);

  /* Enable Fifo and clear TX & RX (p. 305) */
  uart->base_address->FCR = 7;

  /* Set pin mode for the UART to UART0 (TXD0, RXD0)  */
  /* CHANGEME */
  rflpc_pin_set(uart->gpio.port, uart->gpio.rx_pin, uart->gpio.pin_function, 0, 0); /** @todo function value bad for UART3 */
  rflpc_pin_set(uart->gpio.port, uart->gpio.tx_pin, uart->gpio.pin_function, 0, 0);

  /* Reset the DLAB bit in U0LCR to enable access to transmit and receive registers (p. 301) */
  /* CHECKME */
  uart->base_address->LCR &= ~(0x1UL << 7);

  return 0;
}
Beispiel #2
0
static char init(void) {
	rflpc_pin_set(MBED_DIP12, 0, RFLPC_PIN_MODE_RESISTOR_PULL_DOWN, 0);
    rflpc_pin_set(MBED_DIP13, 0, RFLPC_PIN_MODE_RESISTOR_PULL_DOWN, 0);
    rflpc_pin_set(MBED_DIP14, 0, RFLPC_PIN_MODE_RESISTOR_PULL_DOWN, 0);
    rflpc_pin_set(MBED_DIP15, 0, RFLPC_PIN_MODE_RESISTOR_PULL_DOWN, 0);
    rflpc_pin_set(MBED_DIP16, 0, RFLPC_PIN_MODE_RESISTOR_PULL_DOWN, 0);
    rflpc_led_init();
	return set_timer(&timer,100);
}
Beispiel #3
0
static char doGet(struct args_t *args) {
    unsigned i;
    
    rflpc_pin_set(MBED_DIP12, 0, RFLPC_PIN_MODE_RESISTOR_PULL_DOWN, 0);
    rflpc_pin_set(MBED_DIP13, 0, RFLPC_PIN_MODE_RESISTOR_PULL_DOWN, 0);
    rflpc_pin_set(MBED_DIP14, 0, RFLPC_PIN_MODE_RESISTOR_PULL_DOWN, 0);
    rflpc_pin_set(MBED_DIP15, 0, RFLPC_PIN_MODE_RESISTOR_PULL_DOWN, 0);
    rflpc_pin_set(MBED_DIP16, 0, RFLPC_PIN_MODE_RESISTOR_PULL_DOWN, 0);

	change_state();
	
    return 1;
}
Beispiel #4
0
int main()
{
	/*On fait clignoté la led à l'infini*/
	while(1){
		int i;
		/*Pendant un laps de temps, on allume la LED*/	
		for(i = 0; i < 100000; i++){
			rflpc_pin_set(RFLPC_PIN_P0_10, 1, RFLPC_PIN_MODE_RESISTOR_PULL_UP, 0);
		}
		/*Puis on l'eteint durant la meme duree*/
		for(i = 0; i < 100000; i++){
			rflpc_pin_set(RFLPC_PIN_P0_10, 0, RFLPC_PIN_MODE_RESISTOR_PULL_UP, 0);
		}
	}
    return 0;
}