Vince et Yann / Mbed 2 deprecated APP1_customProtocole

Dependencies:   mbed

Fork of APP1_customProtocole by Yann Lemay-Sévigny

Committer:
yannolecool
Date:
Mon Jan 11 04:04:54 2016 +0000
Revision:
5:259661cbf9c3
Child:
6:5c8e02d5ebcc
Ajout de l'interface custom pour le UART

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yannolecool 5:259661cbf9c3 1 #include "customUART.h"
yannolecool 5:259661cbf9c3 2
yannolecool 5:259661cbf9c3 3 CustomUART::CustomUART()
yannolecool 5:259661cbf9c3 4 {
yannolecool 5:259661cbf9c3 5 //Choose the right pin for UART3 port (STEP5)
yannolecool 5:259661cbf9c3 6 volatile int* PINSEL0 = (volatile int*)0x4002C000;
yannolecool 5:259661cbf9c3 7 *PINSEL0 = *PINSEL0 | 0b10 | (0b10 << 2);
yannolecool 5:259661cbf9c3 8
yannolecool 5:259661cbf9c3 9 //Select the good clock to configure the baud rate (STEP2)
yannolecool 5:259661cbf9c3 10 volatile int* PCLKSEL1 = (volatile int*)0x400FC1AC;
yannolecool 5:259661cbf9c3 11 *PCLKSEL1 = *PCLKSEL1 | (0b01 << 18);
yannolecool 5:259661cbf9c3 12
yannolecool 5:259661cbf9c3 13 //Enable the UART3 port (STEP1)
yannolecool 5:259661cbf9c3 14 volatile int* PCONP = (volatile int*)0x400FC0C4;
yannolecool 5:259661cbf9c3 15 *PCONP = *PCONP | (0b1 << 25);
yannolecool 5:259661cbf9c3 16
yannolecool 5:259661cbf9c3 17 //Enable clock division to have good baud rate (STEP3)
yannolecool 5:259661cbf9c3 18 volatile int* U3LCR = (volatile int*)0x4009C00C;
yannolecool 5:259661cbf9c3 19 volatile int* U3DLL = (volatile int*)0x4009C000;
yannolecool 5:259661cbf9c3 20 volatile int* U3DLM = (volatile int*)0x4009C004;
yannolecool 5:259661cbf9c3 21
yannolecool 5:259661cbf9c3 22 *U3LCR = *U3LCR | (0b1 << 7);
yannolecool 5:259661cbf9c3 23 *U3DLM = 0x02;
yannolecool 5:259661cbf9c3 24 *U3DLL = 0x71;
yannolecool 5:259661cbf9c3 25 *U3LCR = 0b11;
yannolecool 5:259661cbf9c3 26
yannolecool 5:259661cbf9c3 27 //Enable the UART FIFO (STEP4)
yannolecool 5:259661cbf9c3 28 volatile int* U3FCR = (volatile int*)0x4009C008;
yannolecool 5:259661cbf9c3 29 *U3FCR = *U3FCR | 0b1;
yannolecool 5:259661cbf9c3 30
yannolecool 5:259661cbf9c3 31
yannolecool 5:259661cbf9c3 32 }
yannolecool 5:259661cbf9c3 33
yannolecool 5:259661cbf9c3 34 void CustomUART::putc(const char caracter)
yannolecool 5:259661cbf9c3 35 {
yannolecool 5:259661cbf9c3 36 volatile int* U3THR = (volatile int*)0x4009C000;
yannolecool 5:259661cbf9c3 37 *U3THR = caracter;
yannolecool 5:259661cbf9c3 38 }
yannolecool 5:259661cbf9c3 39