Vince et Yann / Mbed 2 deprecated APP1_customProtocole

Dependencies:   mbed

Fork of APP1_customProtocole by Yann Lemay-Sévigny

Committer:
yannolecool
Date:
Tue Jan 12 20:28:24 2016 +0000
Revision:
7:7424c51ee942
Parent:
6:5c8e02d5ebcc
Code final comment? avec UART custom

Who changed what in which revision?

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