max32630fthr quad spi , unexpected spi behavior

Committer:
boonshen
Date:
Tue Mar 13 21:12:00 2018 +0000
Revision:
0:a35c40f49345
MAX32630FTHR QuadSPI test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
boonshen 0:a35c40f49345 1 /* mbed Microcontroller Library
boonshen 0:a35c40f49345 2 * Copyright (c) 2006-2013 ARM Limited
boonshen 0:a35c40f49345 3 *
boonshen 0:a35c40f49345 4 * Licensed under the Apache License, Version 2.0 (the "License");
boonshen 0:a35c40f49345 5 * you may not use this file except in compliance with the License.
boonshen 0:a35c40f49345 6 * You may obtain a copy of the License at
boonshen 0:a35c40f49345 7 *
boonshen 0:a35c40f49345 8 * http://www.apache.org/licenses/LICENSE-2.0
boonshen 0:a35c40f49345 9 *
boonshen 0:a35c40f49345 10 * Unless required by applicable law or agreed to in writing, software
boonshen 0:a35c40f49345 11 * distributed under the License is distributed on an "AS IS" BASIS,
boonshen 0:a35c40f49345 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
boonshen 0:a35c40f49345 13 * See the License for the specific language governing permissions and
boonshen 0:a35c40f49345 14 * limitations under the License.
boonshen 0:a35c40f49345 15 */
boonshen 0:a35c40f49345 16 #ifndef MBED_PORTIN_H
boonshen 0:a35c40f49345 17 #define MBED_PORTIN_H
boonshen 0:a35c40f49345 18
boonshen 0:a35c40f49345 19 #include "platform/platform.h"
boonshen 0:a35c40f49345 20
boonshen 0:a35c40f49345 21 #if defined (DEVICE_PORTIN) || defined(DOXYGEN_ONLY)
boonshen 0:a35c40f49345 22
boonshen 0:a35c40f49345 23 #include "hal/port_api.h"
boonshen 0:a35c40f49345 24 #include "platform/mbed_critical.h"
boonshen 0:a35c40f49345 25
boonshen 0:a35c40f49345 26 namespace mbed {
boonshen 0:a35c40f49345 27 /** \addtogroup drivers */
boonshen 0:a35c40f49345 28
boonshen 0:a35c40f49345 29 /** A multiple pin digital input
boonshen 0:a35c40f49345 30 *
boonshen 0:a35c40f49345 31 * @note Synchronization level: Interrupt safe
boonshen 0:a35c40f49345 32 *
boonshen 0:a35c40f49345 33 * Example:
boonshen 0:a35c40f49345 34 * @code
boonshen 0:a35c40f49345 35 * // Switch on an LED if any of mbed pins 21-26 is high
boonshen 0:a35c40f49345 36 *
boonshen 0:a35c40f49345 37 * #include "mbed.h"
boonshen 0:a35c40f49345 38 *
boonshen 0:a35c40f49345 39 * PortIn p(Port2, 0x0000003F); // p21-p26
boonshen 0:a35c40f49345 40 * DigitalOut ind(LED4);
boonshen 0:a35c40f49345 41 *
boonshen 0:a35c40f49345 42 * int main() {
boonshen 0:a35c40f49345 43 * while(1) {
boonshen 0:a35c40f49345 44 * int pins = p.read();
boonshen 0:a35c40f49345 45 * if(pins) {
boonshen 0:a35c40f49345 46 * ind = 1;
boonshen 0:a35c40f49345 47 * } else {
boonshen 0:a35c40f49345 48 * ind = 0;
boonshen 0:a35c40f49345 49 * }
boonshen 0:a35c40f49345 50 * }
boonshen 0:a35c40f49345 51 * }
boonshen 0:a35c40f49345 52 * @endcode
boonshen 0:a35c40f49345 53 * @ingroup drivers
boonshen 0:a35c40f49345 54 */
boonshen 0:a35c40f49345 55 class PortIn {
boonshen 0:a35c40f49345 56 public:
boonshen 0:a35c40f49345 57
boonshen 0:a35c40f49345 58 /** Create an PortIn, connected to the specified port
boonshen 0:a35c40f49345 59 *
boonshen 0:a35c40f49345 60 * @param port Port to connect to (Port0-Port5)
boonshen 0:a35c40f49345 61 * @param mask A bitmask to identify which bits in the port should be included (0 - ignore)
boonshen 0:a35c40f49345 62 */
boonshen 0:a35c40f49345 63 PortIn(PortName port, int mask = 0xFFFFFFFF) {
boonshen 0:a35c40f49345 64 core_util_critical_section_enter();
boonshen 0:a35c40f49345 65 port_init(&_port, port, mask, PIN_INPUT);
boonshen 0:a35c40f49345 66 core_util_critical_section_exit();
boonshen 0:a35c40f49345 67 }
boonshen 0:a35c40f49345 68
boonshen 0:a35c40f49345 69 /** Read the value currently output on the port
boonshen 0:a35c40f49345 70 *
boonshen 0:a35c40f49345 71 * @returns
boonshen 0:a35c40f49345 72 * An integer with each bit corresponding to associated port pin setting
boonshen 0:a35c40f49345 73 */
boonshen 0:a35c40f49345 74 int read() {
boonshen 0:a35c40f49345 75 return port_read(&_port);
boonshen 0:a35c40f49345 76 }
boonshen 0:a35c40f49345 77
boonshen 0:a35c40f49345 78 /** Set the input pin mode
boonshen 0:a35c40f49345 79 *
boonshen 0:a35c40f49345 80 * @param mode PullUp, PullDown, PullNone, OpenDrain
boonshen 0:a35c40f49345 81 */
boonshen 0:a35c40f49345 82 void mode(PinMode mode) {
boonshen 0:a35c40f49345 83 core_util_critical_section_enter();
boonshen 0:a35c40f49345 84 port_mode(&_port, mode);
boonshen 0:a35c40f49345 85 core_util_critical_section_exit();
boonshen 0:a35c40f49345 86 }
boonshen 0:a35c40f49345 87
boonshen 0:a35c40f49345 88 /** A shorthand for read()
boonshen 0:a35c40f49345 89 */
boonshen 0:a35c40f49345 90 operator int() {
boonshen 0:a35c40f49345 91 return read();
boonshen 0:a35c40f49345 92 }
boonshen 0:a35c40f49345 93
boonshen 0:a35c40f49345 94 private:
boonshen 0:a35c40f49345 95 port_t _port;
boonshen 0:a35c40f49345 96 };
boonshen 0:a35c40f49345 97
boonshen 0:a35c40f49345 98 } // namespace mbed
boonshen 0:a35c40f49345 99
boonshen 0:a35c40f49345 100 #endif
boonshen 0:a35c40f49345 101
boonshen 0:a35c40f49345 102 #endif