Contiki 3.x
Macros | Functions
uart.h File Reference

    Provide common UART routines for MK60DZ10.
More...

#include <stdint.h>
#include "K60.h"

Go to the source code of this file.

Macros

#define UART_SBR(f, b)   ((f) / (b * 16))
 UART module SBR parameter based on module frequency f and desired baud rate b.
 
#define UART_BRFA(f, b)   ((((4 * (f)) / (b) + 1) / 2) % 32)
 UART module fine adjust parameter based on module frequency f and desired baud rate b. More...
 

Functions

void uart_module_enable (const unsigned int uart_num)
 Enable the clock gate to an UART module. More...
 
void uart_init (const unsigned int uart_num, uint32_t module_clk_hz, const uint32_t baud)
 Initialize UART. More...
 

Detailed Description

    Provide common UART routines for MK60DZ10.
Author
Tony Persson tony..nosp@m.pers.nosp@m.son@r.nosp@m.ubic.nosp@m.o.com
Joakim Gebart joaki.nosp@m.m.ge.nosp@m.bart@.nosp@m.eist.nosp@m.ec.se

Definition in file uart.h.

Macro Definition Documentation

#define UART_BRFA (   f,
 
)    ((((4 * (f)) / (b) + 1) / 2) % 32)

UART module fine adjust parameter based on module frequency f and desired baud rate b.

Todo:
Verify proper rounding on UART1 fine adjust calculation
Todo:
Verify the UART1 fine-adjust calculations if F_SYS*32 > 2^32 <=> F_SYS > 2^27 (== 134217728)

Definition at line 98 of file uart.h.

Referenced by uart_init().

Function Documentation

void uart_init ( const unsigned int  uart_num,
uint32_t  module_clk_hz,
const uint32_t  baud 
)

Initialize UART.

This is based on the example found in the CodeWarrior samples provided by Freescale.

Parameters
uart_numUART module number
module_clk_hzModule clock (in Hz) of the given UART, if zero: Use current module frequency.
baudDesired target baud rate of the UART.

Definition at line 154 of file uart.c.

References UART_Type::BDH, UART_Type::BDL, UART_Type::C1, UART_Type::C2, UART_Type::C4, DEBUGGER_BREAK, NVIC_EnableIRQ(), ringbuf_init(), SystemBusClock, SystemSysClock, UART0_RX_TX_IRQn, UART1_RX_TX_IRQn, UART2_RX_TX_IRQn, UART3_RX_TX_IRQn, UART4_RX_TX_IRQn, UART5_RX_TX_IRQn, UART_BRFA, uart_module_enable(), and UART_SBR.

Referenced by dbg_uart_init(), main(), and menu_run_sleep().

void uart_module_enable ( const unsigned int  uart_num)

Enable the clock gate to an UART module.

This is a convenience function mapping UART module number to SIM_SCG register.

Parameters
uart_numUART module number

Definition at line 115 of file uart.c.

References BITBAND_REG, DEBUGGER_BREAK, and SIM.

Referenced by ow_init(), and uart_init().