t
Fork of mbed-dev by
targets/hal/TARGET_Atmel/TARGET_SAM_CortexM0P/drivers/sercom/usart/usart_interrupt.h@15:a81a8d6c1dfe, 2015-11-04 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Nov 04 16:30:11 2015 +0000
- Revision:
- 15:a81a8d6c1dfe
Synchronized with git revision 46af745ef4405614c3fa49abbd9a706a362ea514
Full URL: https://github.com/mbedmicro/mbed/commit/46af745ef4405614c3fa49abbd9a706a362ea514/
Renamed TARGET_SAM_CortexM0+ to TARGET_SAM_CortexM0P for compatiblity with online compiler
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 15:a81a8d6c1dfe | 1 | /** |
mbed_official | 15:a81a8d6c1dfe | 2 | * \file |
mbed_official | 15:a81a8d6c1dfe | 3 | * |
mbed_official | 15:a81a8d6c1dfe | 4 | * \brief SAM SERCOM USART Asynchronous Driver |
mbed_official | 15:a81a8d6c1dfe | 5 | * |
mbed_official | 15:a81a8d6c1dfe | 6 | * Copyright (C) 2012-2015 Atmel Corporation. All rights reserved. |
mbed_official | 15:a81a8d6c1dfe | 7 | * |
mbed_official | 15:a81a8d6c1dfe | 8 | * \asf_license_start |
mbed_official | 15:a81a8d6c1dfe | 9 | * |
mbed_official | 15:a81a8d6c1dfe | 10 | * \page License |
mbed_official | 15:a81a8d6c1dfe | 11 | * |
mbed_official | 15:a81a8d6c1dfe | 12 | * Redistribution and use in source and binary forms, with or without |
mbed_official | 15:a81a8d6c1dfe | 13 | * modification, are permitted provided that the following conditions are met: |
mbed_official | 15:a81a8d6c1dfe | 14 | * |
mbed_official | 15:a81a8d6c1dfe | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 15:a81a8d6c1dfe | 16 | * this list of conditions and the following disclaimer. |
mbed_official | 15:a81a8d6c1dfe | 17 | * |
mbed_official | 15:a81a8d6c1dfe | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 15:a81a8d6c1dfe | 19 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 15:a81a8d6c1dfe | 20 | * and/or other materials provided with the distribution. |
mbed_official | 15:a81a8d6c1dfe | 21 | * |
mbed_official | 15:a81a8d6c1dfe | 22 | * 3. The name of Atmel may not be used to endorse or promote products derived |
mbed_official | 15:a81a8d6c1dfe | 23 | * from this software without specific prior written permission. |
mbed_official | 15:a81a8d6c1dfe | 24 | * |
mbed_official | 15:a81a8d6c1dfe | 25 | * 4. This software may only be redistributed and used in connection with an |
mbed_official | 15:a81a8d6c1dfe | 26 | * Atmel microcontroller product. |
mbed_official | 15:a81a8d6c1dfe | 27 | * |
mbed_official | 15:a81a8d6c1dfe | 28 | * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED |
mbed_official | 15:a81a8d6c1dfe | 29 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
mbed_official | 15:a81a8d6c1dfe | 30 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE |
mbed_official | 15:a81a8d6c1dfe | 31 | * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR |
mbed_official | 15:a81a8d6c1dfe | 32 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 15:a81a8d6c1dfe | 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
mbed_official | 15:a81a8d6c1dfe | 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
mbed_official | 15:a81a8d6c1dfe | 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
mbed_official | 15:a81a8d6c1dfe | 36 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
mbed_official | 15:a81a8d6c1dfe | 37 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
mbed_official | 15:a81a8d6c1dfe | 38 | * POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 15:a81a8d6c1dfe | 39 | * |
mbed_official | 15:a81a8d6c1dfe | 40 | * \asf_license_stop |
mbed_official | 15:a81a8d6c1dfe | 41 | * |
mbed_official | 15:a81a8d6c1dfe | 42 | */ |
mbed_official | 15:a81a8d6c1dfe | 43 | /* |
mbed_official | 15:a81a8d6c1dfe | 44 | * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a> |
mbed_official | 15:a81a8d6c1dfe | 45 | */ |
mbed_official | 15:a81a8d6c1dfe | 46 | #ifndef USART_INTERRUPT_H_INCLUDED |
mbed_official | 15:a81a8d6c1dfe | 47 | #define USART_INTERRUPT_H_INCLUDED |
mbed_official | 15:a81a8d6c1dfe | 48 | |
mbed_official | 15:a81a8d6c1dfe | 49 | #include "usart.h" |
mbed_official | 15:a81a8d6c1dfe | 50 | |
mbed_official | 15:a81a8d6c1dfe | 51 | #ifdef __cplusplus |
mbed_official | 15:a81a8d6c1dfe | 52 | extern "C" { |
mbed_official | 15:a81a8d6c1dfe | 53 | #endif |
mbed_official | 15:a81a8d6c1dfe | 54 | |
mbed_official | 15:a81a8d6c1dfe | 55 | #if !defined(__DOXYGEN__) |
mbed_official | 15:a81a8d6c1dfe | 56 | enum status_code _usart_write_buffer( |
mbed_official | 15:a81a8d6c1dfe | 57 | struct usart_module *const module, |
mbed_official | 15:a81a8d6c1dfe | 58 | uint8_t *tx_data, |
mbed_official | 15:a81a8d6c1dfe | 59 | uint16_t length); |
mbed_official | 15:a81a8d6c1dfe | 60 | |
mbed_official | 15:a81a8d6c1dfe | 61 | enum status_code _usart_read_buffer( |
mbed_official | 15:a81a8d6c1dfe | 62 | struct usart_module *const module, |
mbed_official | 15:a81a8d6c1dfe | 63 | uint8_t *rx_data, |
mbed_official | 15:a81a8d6c1dfe | 64 | uint16_t length); |
mbed_official | 15:a81a8d6c1dfe | 65 | |
mbed_official | 15:a81a8d6c1dfe | 66 | void _usart_interrupt_handler( |
mbed_official | 15:a81a8d6c1dfe | 67 | uint8_t instance); |
mbed_official | 15:a81a8d6c1dfe | 68 | #endif |
mbed_official | 15:a81a8d6c1dfe | 69 | |
mbed_official | 15:a81a8d6c1dfe | 70 | /** |
mbed_official | 15:a81a8d6c1dfe | 71 | * \addtogroup asfdoc_sam0_sercom_usart_group |
mbed_official | 15:a81a8d6c1dfe | 72 | * |
mbed_official | 15:a81a8d6c1dfe | 73 | * @{ |
mbed_official | 15:a81a8d6c1dfe | 74 | */ |
mbed_official | 15:a81a8d6c1dfe | 75 | |
mbed_official | 15:a81a8d6c1dfe | 76 | /** |
mbed_official | 15:a81a8d6c1dfe | 77 | * \name Callback Management |
mbed_official | 15:a81a8d6c1dfe | 78 | * @{ |
mbed_official | 15:a81a8d6c1dfe | 79 | */ |
mbed_official | 15:a81a8d6c1dfe | 80 | void usart_register_callback( |
mbed_official | 15:a81a8d6c1dfe | 81 | struct usart_module *const module, |
mbed_official | 15:a81a8d6c1dfe | 82 | usart_callback_t callback_func, |
mbed_official | 15:a81a8d6c1dfe | 83 | enum usart_callback callback_type); |
mbed_official | 15:a81a8d6c1dfe | 84 | |
mbed_official | 15:a81a8d6c1dfe | 85 | void usart_unregister_callback( |
mbed_official | 15:a81a8d6c1dfe | 86 | struct usart_module *module, |
mbed_official | 15:a81a8d6c1dfe | 87 | enum usart_callback callback_type); |
mbed_official | 15:a81a8d6c1dfe | 88 | |
mbed_official | 15:a81a8d6c1dfe | 89 | /** |
mbed_official | 15:a81a8d6c1dfe | 90 | * \brief Enables callback |
mbed_official | 15:a81a8d6c1dfe | 91 | * |
mbed_official | 15:a81a8d6c1dfe | 92 | * Enables the callback function registered by the \ref usart_register_callback. |
mbed_official | 15:a81a8d6c1dfe | 93 | * The callback function will be called from the interrupt handler when the |
mbed_official | 15:a81a8d6c1dfe | 94 | * conditions for the callback type are met. |
mbed_official | 15:a81a8d6c1dfe | 95 | * |
mbed_official | 15:a81a8d6c1dfe | 96 | * \param[in] module Pointer to USART software instance struct |
mbed_official | 15:a81a8d6c1dfe | 97 | * \param[in] callback_type Callback type given by an enum |
mbed_official | 15:a81a8d6c1dfe | 98 | */ |
mbed_official | 15:a81a8d6c1dfe | 99 | static inline void usart_enable_callback( |
mbed_official | 15:a81a8d6c1dfe | 100 | struct usart_module *const module, |
mbed_official | 15:a81a8d6c1dfe | 101 | enum usart_callback callback_type) |
mbed_official | 15:a81a8d6c1dfe | 102 | { |
mbed_official | 15:a81a8d6c1dfe | 103 | /* Sanity check arguments */ |
mbed_official | 15:a81a8d6c1dfe | 104 | Assert(module); |
mbed_official | 15:a81a8d6c1dfe | 105 | |
mbed_official | 15:a81a8d6c1dfe | 106 | /* Enable callback */ |
mbed_official | 15:a81a8d6c1dfe | 107 | module->callback_enable_mask |= (1 << callback_type); |
mbed_official | 15:a81a8d6c1dfe | 108 | |
mbed_official | 15:a81a8d6c1dfe | 109 | } |
mbed_official | 15:a81a8d6c1dfe | 110 | |
mbed_official | 15:a81a8d6c1dfe | 111 | /** |
mbed_official | 15:a81a8d6c1dfe | 112 | * \brief Disable callback |
mbed_official | 15:a81a8d6c1dfe | 113 | * |
mbed_official | 15:a81a8d6c1dfe | 114 | * Disables the callback function registered by the \ref usart_register_callback, |
mbed_official | 15:a81a8d6c1dfe | 115 | * and the callback will not be called from the interrupt routine. |
mbed_official | 15:a81a8d6c1dfe | 116 | * |
mbed_official | 15:a81a8d6c1dfe | 117 | * \param[in] module Pointer to USART software instance struct |
mbed_official | 15:a81a8d6c1dfe | 118 | * \param[in] callback_type Callback type given by an enum |
mbed_official | 15:a81a8d6c1dfe | 119 | */ |
mbed_official | 15:a81a8d6c1dfe | 120 | static inline void usart_disable_callback( |
mbed_official | 15:a81a8d6c1dfe | 121 | struct usart_module *const module, |
mbed_official | 15:a81a8d6c1dfe | 122 | enum usart_callback callback_type) |
mbed_official | 15:a81a8d6c1dfe | 123 | { |
mbed_official | 15:a81a8d6c1dfe | 124 | /* Sanity check arguments */ |
mbed_official | 15:a81a8d6c1dfe | 125 | Assert(module); |
mbed_official | 15:a81a8d6c1dfe | 126 | |
mbed_official | 15:a81a8d6c1dfe | 127 | /* Disable callback */ |
mbed_official | 15:a81a8d6c1dfe | 128 | module->callback_enable_mask &= ~(1 << callback_type); |
mbed_official | 15:a81a8d6c1dfe | 129 | } |
mbed_official | 15:a81a8d6c1dfe | 130 | |
mbed_official | 15:a81a8d6c1dfe | 131 | /** |
mbed_official | 15:a81a8d6c1dfe | 132 | * @} |
mbed_official | 15:a81a8d6c1dfe | 133 | */ |
mbed_official | 15:a81a8d6c1dfe | 134 | |
mbed_official | 15:a81a8d6c1dfe | 135 | /** |
mbed_official | 15:a81a8d6c1dfe | 136 | * \name Writing and Reading |
mbed_official | 15:a81a8d6c1dfe | 137 | * @{ |
mbed_official | 15:a81a8d6c1dfe | 138 | */ |
mbed_official | 15:a81a8d6c1dfe | 139 | enum status_code usart_write_job( |
mbed_official | 15:a81a8d6c1dfe | 140 | struct usart_module *const module, |
mbed_official | 15:a81a8d6c1dfe | 141 | const uint16_t *tx_data); |
mbed_official | 15:a81a8d6c1dfe | 142 | |
mbed_official | 15:a81a8d6c1dfe | 143 | enum status_code usart_read_job( |
mbed_official | 15:a81a8d6c1dfe | 144 | struct usart_module *const module, |
mbed_official | 15:a81a8d6c1dfe | 145 | uint16_t *const rx_data); |
mbed_official | 15:a81a8d6c1dfe | 146 | |
mbed_official | 15:a81a8d6c1dfe | 147 | enum status_code usart_write_buffer_job( |
mbed_official | 15:a81a8d6c1dfe | 148 | struct usart_module *const module, |
mbed_official | 15:a81a8d6c1dfe | 149 | uint8_t *tx_data, |
mbed_official | 15:a81a8d6c1dfe | 150 | uint16_t length); |
mbed_official | 15:a81a8d6c1dfe | 151 | |
mbed_official | 15:a81a8d6c1dfe | 152 | enum status_code usart_read_buffer_job( |
mbed_official | 15:a81a8d6c1dfe | 153 | struct usart_module *const module, |
mbed_official | 15:a81a8d6c1dfe | 154 | uint8_t *rx_data, |
mbed_official | 15:a81a8d6c1dfe | 155 | uint16_t length); |
mbed_official | 15:a81a8d6c1dfe | 156 | |
mbed_official | 15:a81a8d6c1dfe | 157 | void usart_abort_job( |
mbed_official | 15:a81a8d6c1dfe | 158 | struct usart_module *const module, |
mbed_official | 15:a81a8d6c1dfe | 159 | enum usart_transceiver_type transceiver_type); |
mbed_official | 15:a81a8d6c1dfe | 160 | |
mbed_official | 15:a81a8d6c1dfe | 161 | enum status_code usart_get_job_status( |
mbed_official | 15:a81a8d6c1dfe | 162 | struct usart_module *const module, |
mbed_official | 15:a81a8d6c1dfe | 163 | enum usart_transceiver_type transceiver_type); |
mbed_official | 15:a81a8d6c1dfe | 164 | /** |
mbed_official | 15:a81a8d6c1dfe | 165 | * @} |
mbed_official | 15:a81a8d6c1dfe | 166 | */ |
mbed_official | 15:a81a8d6c1dfe | 167 | |
mbed_official | 15:a81a8d6c1dfe | 168 | /** |
mbed_official | 15:a81a8d6c1dfe | 169 | * @} |
mbed_official | 15:a81a8d6c1dfe | 170 | */ |
mbed_official | 15:a81a8d6c1dfe | 171 | |
mbed_official | 15:a81a8d6c1dfe | 172 | #ifdef __cplusplus |
mbed_official | 15:a81a8d6c1dfe | 173 | } |
mbed_official | 15:a81a8d6c1dfe | 174 | #endif |
mbed_official | 15:a81a8d6c1dfe | 175 | |
mbed_official | 15:a81a8d6c1dfe | 176 | #endif /* USART_INTERRUPT_H_INCLUDED */ |
mbed_official | 15:a81a8d6c1dfe | 177 |