mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri Jul 17 09:15:10 2015 +0100
Revision:
592:a274ee790e56
Parent:
579:53297373a894
Synchronized with git revision e7144f83a8d75df80c4877936b6ffe552b0be9e6

Full URL: https://github.com/mbedmicro/mbed/commit/e7144f83a8d75df80c4877936b6ffe552b0be9e6/

More API implementation for SAMR21

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 579:53297373a894 1 #ifndef USART_INTERRUPT_H_INCLUDED
mbed_official 579:53297373a894 2 #define USART_INTERRUPT_H_INCLUDED
mbed_official 579:53297373a894 3
mbed_official 579:53297373a894 4 #include "usart.h"
mbed_official 579:53297373a894 5
mbed_official 579:53297373a894 6 #ifdef __cplusplus
mbed_official 579:53297373a894 7 extern "C" {
mbed_official 579:53297373a894 8 #endif
mbed_official 579:53297373a894 9
mbed_official 579:53297373a894 10 #if !defined(__DOXYGEN__)
mbed_official 579:53297373a894 11 void _usart_write_buffer(
mbed_official 579:53297373a894 12 struct usart_module *const module,
mbed_official 579:53297373a894 13 uint8_t *tx_data,
mbed_official 579:53297373a894 14 uint16_t length);
mbed_official 579:53297373a894 15
mbed_official 579:53297373a894 16 void _usart_read_buffer(
mbed_official 579:53297373a894 17 struct usart_module *const module,
mbed_official 579:53297373a894 18 uint8_t *rx_data,
mbed_official 579:53297373a894 19 uint16_t length);
mbed_official 579:53297373a894 20
mbed_official 579:53297373a894 21 void _usart_interrupt_handler(
mbed_official 579:53297373a894 22 uint8_t instance);
mbed_official 579:53297373a894 23 #endif
mbed_official 579:53297373a894 24
mbed_official 579:53297373a894 25 /**
mbed_official 579:53297373a894 26 * \addtogroup asfdoc_sam0_sercom_usart_group
mbed_official 579:53297373a894 27 *
mbed_official 579:53297373a894 28 * @{
mbed_official 579:53297373a894 29 */
mbed_official 579:53297373a894 30
mbed_official 579:53297373a894 31 /**
mbed_official 579:53297373a894 32 * \name Callback Management
mbed_official 579:53297373a894 33 * @{
mbed_official 579:53297373a894 34 */
mbed_official 579:53297373a894 35 void usart_register_callback(
mbed_official 579:53297373a894 36 struct usart_module *const module,
mbed_official 579:53297373a894 37 usart_callback_t callback_func,
mbed_official 579:53297373a894 38 enum usart_callback callback_type);
mbed_official 579:53297373a894 39
mbed_official 579:53297373a894 40 void usart_unregister_callback(
mbed_official 579:53297373a894 41 struct usart_module *module,
mbed_official 579:53297373a894 42 enum usart_callback callback_type);
mbed_official 579:53297373a894 43
mbed_official 579:53297373a894 44 /**
mbed_official 579:53297373a894 45 * \brief Enables callback
mbed_official 579:53297373a894 46 *
mbed_official 579:53297373a894 47 * Enables the callback function registered by the \ref usart_register_callback.
mbed_official 579:53297373a894 48 * The callback function will be called from the interrupt handler when the
mbed_official 579:53297373a894 49 * conditions for the callback type are met.
mbed_official 579:53297373a894 50 *
mbed_official 579:53297373a894 51 * \param[in] module Pointer to USART software instance struct
mbed_official 579:53297373a894 52 * \param[in] callback_type Callback type given by an enum
mbed_official 579:53297373a894 53 */
mbed_official 579:53297373a894 54 static inline void usart_enable_callback(
mbed_official 579:53297373a894 55 struct usart_module *const module,
mbed_official 579:53297373a894 56 enum usart_callback callback_type)
mbed_official 579:53297373a894 57 {
mbed_official 579:53297373a894 58 /* Sanity check arguments */
mbed_official 579:53297373a894 59 Assert(module);
mbed_official 579:53297373a894 60
mbed_official 579:53297373a894 61 /* Enable callback */
mbed_official 579:53297373a894 62 module->callback_enable_mask |= (1 << callback_type);
mbed_official 579:53297373a894 63
mbed_official 579:53297373a894 64 }
mbed_official 579:53297373a894 65
mbed_official 579:53297373a894 66 /**
mbed_official 579:53297373a894 67 * \brief Disable callback
mbed_official 579:53297373a894 68 *
mbed_official 579:53297373a894 69 * Disables the callback function registered by the \ref usart_register_callback,
mbed_official 579:53297373a894 70 * and the callback will not be called from the interrupt routine.
mbed_official 579:53297373a894 71 *
mbed_official 579:53297373a894 72 * \param[in] module Pointer to USART software instance struct
mbed_official 579:53297373a894 73 * \param[in] callback_type Callback type given by an enum
mbed_official 579:53297373a894 74 */
mbed_official 579:53297373a894 75 static inline void usart_disable_callback(
mbed_official 579:53297373a894 76 struct usart_module *const module,
mbed_official 579:53297373a894 77 enum usart_callback callback_type)
mbed_official 579:53297373a894 78 {
mbed_official 579:53297373a894 79 /* Sanity check arguments */
mbed_official 579:53297373a894 80 Assert(module);
mbed_official 579:53297373a894 81
mbed_official 579:53297373a894 82 /* Disable callback */
mbed_official 579:53297373a894 83 module->callback_enable_mask &= ~(1 << callback_type);
mbed_official 579:53297373a894 84 }
mbed_official 579:53297373a894 85
mbed_official 579:53297373a894 86 /**
mbed_official 579:53297373a894 87 * @}
mbed_official 579:53297373a894 88 */
mbed_official 579:53297373a894 89
mbed_official 579:53297373a894 90 /**
mbed_official 579:53297373a894 91 * \name Writing and Reading
mbed_official 579:53297373a894 92 * @{
mbed_official 579:53297373a894 93 */
mbed_official 579:53297373a894 94 enum status_code usart_write_job(
mbed_official 579:53297373a894 95 struct usart_module *const module,
mbed_official 579:53297373a894 96 const uint16_t *tx_data);
mbed_official 579:53297373a894 97
mbed_official 579:53297373a894 98 enum status_code usart_read_job(
mbed_official 579:53297373a894 99 struct usart_module *const module,
mbed_official 579:53297373a894 100 uint16_t *const rx_data);
mbed_official 579:53297373a894 101
mbed_official 579:53297373a894 102 enum status_code usart_write_buffer_job(
mbed_official 579:53297373a894 103 struct usart_module *const module,
mbed_official 579:53297373a894 104 uint8_t *tx_data,
mbed_official 579:53297373a894 105 uint16_t length);
mbed_official 579:53297373a894 106
mbed_official 579:53297373a894 107 enum status_code usart_read_buffer_job(
mbed_official 579:53297373a894 108 struct usart_module *const module,
mbed_official 579:53297373a894 109 uint8_t *rx_data,
mbed_official 579:53297373a894 110 uint16_t length);
mbed_official 579:53297373a894 111
mbed_official 579:53297373a894 112 void usart_abort_job(
mbed_official 579:53297373a894 113 struct usart_module *const module,
mbed_official 579:53297373a894 114 enum usart_transceiver_type transceiver_type);
mbed_official 579:53297373a894 115
mbed_official 579:53297373a894 116 enum status_code usart_get_job_status(
mbed_official 579:53297373a894 117 struct usart_module *const module,
mbed_official 579:53297373a894 118 enum usart_transceiver_type transceiver_type);
mbed_official 579:53297373a894 119 /**
mbed_official 579:53297373a894 120 * @}
mbed_official 579:53297373a894 121 */
mbed_official 579:53297373a894 122
mbed_official 579:53297373a894 123 /**
mbed_official 579:53297373a894 124 * @}
mbed_official 579:53297373a894 125 */
mbed_official 579:53297373a894 126
mbed_official 579:53297373a894 127 #ifdef __cplusplus
mbed_official 579:53297373a894 128 }
mbed_official 579:53297373a894 129 #endif
mbed_official 579:53297373a894 130
mbed_official 579:53297373a894 131 #endif /* USART_INTERRUPT_H_INCLUDED */