Platform-specific devices.
This commit is contained in:
parent
792056e325
commit
ae2e9f3677
16 changed files with 2399 additions and 0 deletions
120
platform/msb430/dev/msb430-uart1.h
Normal file
120
platform/msb430/dev/msb430-uart1.h
Normal file
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
Copyright 2007, Freie Universitaet Berlin. All rights reserved.
|
||||
|
||||
These sources were developed at the Freie Universität Berlin, Computer
|
||||
Systems and Telematics group.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of Freie Universitaet Berlin (FUB) nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
This software is provided by FUB and the contributors on an "as is"
|
||||
basis, without any representations or warranties of any kind, express
|
||||
or implied including, but not limited to, representations or
|
||||
warranties of non-infringement, merchantability or fitness for a
|
||||
particular purpose. In no event shall FUB or contributors be liable
|
||||
for any direct, indirect, incidental, special, exemplary, or
|
||||
consequential damages (including, but not limited to, procurement of
|
||||
substitute goods or services; loss of use, data, or profits; or
|
||||
business interruption) however caused and on any theory of liability,
|
||||
whether in contract, strict liability, or tort (including negligence
|
||||
or otherwise) arising in any way out of the use of this software, even
|
||||
if advised of the possibility of such damage.
|
||||
|
||||
This implementation was developed by the CST group at the FUB.
|
||||
|
||||
For documentation and questions please use the web site
|
||||
http://scatterweb.mi.fu-berlin.de and the mailinglist
|
||||
scatterweb@lists.spline.inf.fu-berlin.de (subscription via the Website).
|
||||
Berlin, 2007
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup interfaces
|
||||
* @{ */
|
||||
|
||||
/**
|
||||
* @defgroup uart1 UART1
|
||||
* The UART module multiplexes differenct protocol on the MSB's UART1
|
||||
* interface. Currently RS232 and SPI are supported.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file ScatterWeb.Uart.h
|
||||
* @author Michael Baar <baar@inf.fu-berlin.de>
|
||||
*
|
||||
* Header file for MSP430 UART driver.
|
||||
*/
|
||||
|
||||
#ifndef __UART_H__
|
||||
#define __UART_H__
|
||||
|
||||
#define UART_RX RXBUF1
|
||||
#define UART_TX TXBUF1
|
||||
#define UART_RESET_RX() do { U1IFG &= ~URXIFG1; } while(0)
|
||||
#define UART_RESET_RXTX() do { U1IFG &= ~(URXIFG1 | UTXIFG1); } while(0)
|
||||
#define UART_WAIT_RX() while( (U1IFG & URXIFG1) == 0 ) { _NOP(); }
|
||||
#define UART_WAIT_TX() while( (U1IFG & UTXIFG1) == 0 ) { _NOP(); }
|
||||
#define UART_WAIT_TXDONE() while( (UTCTL1 & TXEPT) == 0 ) { _NOP(); }
|
||||
|
||||
/**
|
||||
* @brief Operating state
|
||||
*/
|
||||
extern volatile unsigned char uart_mode;
|
||||
extern volatile unsigned char uart_lockcnt;
|
||||
|
||||
/**
|
||||
* @name UART mode flags
|
||||
* @{
|
||||
*/
|
||||
#define UART_MODE_RS232 (0x00u) ///< RS232 mode
|
||||
#define UART_MODE_SPI (0x01u) ///< SPI mode
|
||||
#define UART_MODE_DEFAULT UART_MODE_RS232
|
||||
#define UART_NUM_MODES (UART_MODE_SPI + 1) ///< Highest mode number
|
||||
#define UART_MODE_RESET (0xFFu) ///< reset with current settings
|
||||
/** @} */
|
||||
|
||||
#define UART_WAIT_LOCK(x) ( (uart_mode != x ) && (uart_lockcnt) )
|
||||
#define UART_MODE_IS(x) ( uart_mode == x )
|
||||
|
||||
#if 0
|
||||
#ifdef __SCATTERWEB__
|
||||
typedef void(*fp_uart_handler)(void);
|
||||
#else
|
||||
typedef unsigned int(*fp_uart_handler)(unsigned char);
|
||||
#endif
|
||||
#endif
|
||||
typedef unsigned int(*fp_uart_handler)(unsigned char);
|
||||
|
||||
/**
|
||||
* \brief Initialize the UART module
|
||||
*
|
||||
* This function is called from the boot up code to
|
||||
* initalize the UART module.
|
||||
*/
|
||||
void uart_init(void);
|
||||
|
||||
void uart_set_speed(unsigned char mode, unsigned char ubr0, unsigned char ubr1, unsigned char umctl);
|
||||
|
||||
void uart_set_handler(unsigned char mode, fp_uart_handler fpHandler);
|
||||
|
||||
char uart_lock(unsigned char mode);
|
||||
|
||||
char uart_unlock(unsigned char mode);
|
||||
|
||||
#endif /* __UART_H__ */
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
Loading…
Add table
Add a link
Reference in a new issue