Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sat Jun 03 00:22:44 2017 +0000
Revision:
46:b156ef445742
Parent:
18:6a4db94011d3
Final code for internal battlebot competition.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /**
sahilmgandhi 18:6a4db94011d3 2 * \file
sahilmgandhi 18:6a4db94011d3 3 *
sahilmgandhi 18:6a4db94011d3 4 * \brief FLEXCOM driver for SAM.
sahilmgandhi 18:6a4db94011d3 5 *
sahilmgandhi 18:6a4db94011d3 6 * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
sahilmgandhi 18:6a4db94011d3 7 *
sahilmgandhi 18:6a4db94011d3 8 * \asf_license_start
sahilmgandhi 18:6a4db94011d3 9 *
sahilmgandhi 18:6a4db94011d3 10 * \page License
sahilmgandhi 18:6a4db94011d3 11 *
sahilmgandhi 18:6a4db94011d3 12 * Redistribution and use in source and binary forms, with or without
sahilmgandhi 18:6a4db94011d3 13 * modification, are permitted provided that the following conditions are met:
sahilmgandhi 18:6a4db94011d3 14 *
sahilmgandhi 18:6a4db94011d3 15 * 1. Redistributions of source code must retain the above copyright notice,
sahilmgandhi 18:6a4db94011d3 16 * this list of conditions and the following disclaimer.
sahilmgandhi 18:6a4db94011d3 17 *
sahilmgandhi 18:6a4db94011d3 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
sahilmgandhi 18:6a4db94011d3 19 * this list of conditions and the following disclaimer in the documentation
sahilmgandhi 18:6a4db94011d3 20 * and/or other materials provided with the distribution.
sahilmgandhi 18:6a4db94011d3 21 *
sahilmgandhi 18:6a4db94011d3 22 * 3. The name of Atmel may not be used to endorse or promote products derived
sahilmgandhi 18:6a4db94011d3 23 * from this software without specific prior written permission.
sahilmgandhi 18:6a4db94011d3 24 *
sahilmgandhi 18:6a4db94011d3 25 * 4. This software may only be redistributed and used in connection with an
sahilmgandhi 18:6a4db94011d3 26 * Atmel microcontroller product.
sahilmgandhi 18:6a4db94011d3 27 *
sahilmgandhi 18:6a4db94011d3 28 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
sahilmgandhi 18:6a4db94011d3 29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
sahilmgandhi 18:6a4db94011d3 30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
sahilmgandhi 18:6a4db94011d3 31 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
sahilmgandhi 18:6a4db94011d3 32 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sahilmgandhi 18:6a4db94011d3 33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sahilmgandhi 18:6a4db94011d3 34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sahilmgandhi 18:6a4db94011d3 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
sahilmgandhi 18:6a4db94011d3 36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
sahilmgandhi 18:6a4db94011d3 37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
sahilmgandhi 18:6a4db94011d3 38 * POSSIBILITY OF SUCH DAMAGE.
sahilmgandhi 18:6a4db94011d3 39 *
sahilmgandhi 18:6a4db94011d3 40 * \asf_license_stop
sahilmgandhi 18:6a4db94011d3 41 *
sahilmgandhi 18:6a4db94011d3 42 */
sahilmgandhi 18:6a4db94011d3 43 /*
sahilmgandhi 18:6a4db94011d3 44 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
sahilmgandhi 18:6a4db94011d3 45 */
sahilmgandhi 18:6a4db94011d3 46
sahilmgandhi 18:6a4db94011d3 47 #ifndef FLEXCOM_H_INCLUDED
sahilmgandhi 18:6a4db94011d3 48 #define FLEXCOM_H_INCLUDED
sahilmgandhi 18:6a4db94011d3 49
sahilmgandhi 18:6a4db94011d3 50 #include "compiler.h"
sahilmgandhi 18:6a4db94011d3 51 #include "status_codes.h"
sahilmgandhi 18:6a4db94011d3 52
sahilmgandhi 18:6a4db94011d3 53 /// @cond 0
sahilmgandhi 18:6a4db94011d3 54 /**INDENT-OFF**/
sahilmgandhi 18:6a4db94011d3 55 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 56 extern "C" {
sahilmgandhi 18:6a4db94011d3 57 #endif
sahilmgandhi 18:6a4db94011d3 58 /**INDENT-ON**/
sahilmgandhi 18:6a4db94011d3 59 /// @endcond
sahilmgandhi 18:6a4db94011d3 60
sahilmgandhi 18:6a4db94011d3 61 /**
sahilmgandhi 18:6a4db94011d3 62 * \defgroup sam_drivers_flexcom_group Flexible Serial Communication Controller
sahilmgandhi 18:6a4db94011d3 63 * (FLEXCOM) Driver.
sahilmgandhi 18:6a4db94011d3 64 *
sahilmgandhi 18:6a4db94011d3 65 * \par Purpose
sahilmgandhi 18:6a4db94011d3 66 *
sahilmgandhi 18:6a4db94011d3 67 * The Flexible Serial Communication Controller (FLEXCOM) offers several
sahilmgandhi 18:6a4db94011d3 68 * serial communication protocols that are managed by the three submodules
sahilmgandhi 18:6a4db94011d3 69 * USART, SPI, and TWI.
sahilmgandhi 18:6a4db94011d3 70 * @{
sahilmgandhi 18:6a4db94011d3 71 */
sahilmgandhi 18:6a4db94011d3 72
sahilmgandhi 18:6a4db94011d3 73 /**
sahilmgandhi 18:6a4db94011d3 74 * FLEXCOM opration Mode
sahilmgandhi 18:6a4db94011d3 75 */
sahilmgandhi 18:6a4db94011d3 76 enum flexcom_opmode {
sahilmgandhi 18:6a4db94011d3 77 FLEXCOM_NONE = FLEXCOM_MR_OPMODE_NO_COM,
sahilmgandhi 18:6a4db94011d3 78 FLEXCOM_USART = FLEXCOM_MR_OPMODE_USART,
sahilmgandhi 18:6a4db94011d3 79 FLEXCOM_SPI = FLEXCOM_MR_OPMODE_SPI,
sahilmgandhi 18:6a4db94011d3 80 FLEXCOM_TWI = FLEXCOM_MR_OPMODE_TWI,
sahilmgandhi 18:6a4db94011d3 81 };
sahilmgandhi 18:6a4db94011d3 82
sahilmgandhi 18:6a4db94011d3 83 void flexcom_enable(Flexcom *p_flexcom);
sahilmgandhi 18:6a4db94011d3 84 void flexcom_disable(Flexcom *p_flexcom);
sahilmgandhi 18:6a4db94011d3 85 void flexcom_set_opmode(Flexcom *p_flexcom, enum flexcom_opmode opmode);
sahilmgandhi 18:6a4db94011d3 86 void flexcom_get_opmode(Flexcom *p_flexcom, enum flexcom_opmode *opmode);
sahilmgandhi 18:6a4db94011d3 87 void flexcom_write(Flexcom *p_flexcom, uint32_t data);
sahilmgandhi 18:6a4db94011d3 88 void flexcom_read(Flexcom *p_flexcom, uint32_t *data);
sahilmgandhi 18:6a4db94011d3 89
sahilmgandhi 18:6a4db94011d3 90 /** @} */
sahilmgandhi 18:6a4db94011d3 91
sahilmgandhi 18:6a4db94011d3 92 /// @cond 0
sahilmgandhi 18:6a4db94011d3 93 /**INDENT-OFF**/
sahilmgandhi 18:6a4db94011d3 94 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 95 }
sahilmgandhi 18:6a4db94011d3 96 #endif
sahilmgandhi 18:6a4db94011d3 97 /**INDENT-ON**/
sahilmgandhi 18:6a4db94011d3 98 /// @endcond
sahilmgandhi 18:6a4db94011d3 99
sahilmgandhi 18:6a4db94011d3 100 /**
sahilmgandhi 18:6a4db94011d3 101 * \page sam_flexcom_quickstart Quickstart guide for SAM FLEXCOM module
sahilmgandhi 18:6a4db94011d3 102 *
sahilmgandhi 18:6a4db94011d3 103 * This is the quickstart guide for the "SAM FLEXCOM module", with
sahilmgandhi 18:6a4db94011d3 104 * instructions on how to configure and use the module in a selection of use
sahilmgandhi 18:6a4db94011d3 105 * cases. All details related to these submodules(USART/SPI/TWI)
sahilmgandhi 18:6a4db94011d3 106 * are provided in independent sections.
sahilmgandhi 18:6a4db94011d3 107 *
sahilmgandhi 18:6a4db94011d3 108 * The use cases contain several code fragments. The code fragments in the
sahilmgandhi 18:6a4db94011d3 109 * steps for setup can be copied into a custom initialization function, while
sahilmgandhi 18:6a4db94011d3 110 * the steps for usage can be copied into, e.g.the main application function.
sahilmgandhi 18:6a4db94011d3 111 *
sahilmgandhi 18:6a4db94011d3 112 * \section flexcom_use_cases FLEXCOM use cases
sahilmgandhi 18:6a4db94011d3 113 * - \ref flexcom_basic_use_case
sahilmgandhi 18:6a4db94011d3 114 *
sahilmgandhi 18:6a4db94011d3 115 * \section flexcom_basic_use_case Basic use case
sahilmgandhi 18:6a4db94011d3 116 *
sahilmgandhi 18:6a4db94011d3 117 * \subsection sam_flexcom_quickstart_prereq Prerequisites
sahilmgandhi 18:6a4db94011d3 118 * -# \ref sysclk_group "System Clock Management (Sysclock)"
sahilmgandhi 18:6a4db94011d3 119 *
sahilmgandhi 18:6a4db94011d3 120 *
sahilmgandhi 18:6a4db94011d3 121 * \section flexcom_basic_use_case_setup Setup steps
sahilmgandhi 18:6a4db94011d3 122 * \subsection flexcom_basic_use_case_setup_code Example code
sahilmgandhi 18:6a4db94011d3 123 * -# Enable flexcom module access:
sahilmgandhi 18:6a4db94011d3 124 * - \code flexcom_enable(FLEXCOM0); \endcode
sahilmgandhi 18:6a4db94011d3 125 * -# Set flexcom operation module:
sahilmgandhi 18:6a4db94011d3 126 * - \code flexcom_set_opmode(FLEXCOM0, FLEXCOM_USART); \endcode
sahilmgandhi 18:6a4db94011d3 127 *
sahilmgandhi 18:6a4db94011d3 128 * \section flexcom_basic_use_case_usage Usage steps
sahilmgandhi 18:6a4db94011d3 129 * \subsection flexcom_basic_use_case_usage_flow Workflow
sahilmgandhi 18:6a4db94011d3 130 * -# Use write/read function to access the data
sahilmgandhi 18:6a4db94011d3 131 * \code
sahilmgandhi 18:6a4db94011d3 132 flexcom_write(FLEXCOM0, data);
sahilmgandhi 18:6a4db94011d3 133 flexcom_read(FLEXCOM0, &data);
sahilmgandhi 18:6a4db94011d3 134 \endcode
sahilmgandhi 18:6a4db94011d3 135 */
sahilmgandhi 18:6a4db94011d3 136
sahilmgandhi 18:6a4db94011d3 137 #endif /* FLEXCOM_H_INCLUDED */