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-2012 ARM Limited
boonshen 0:a35c40f49345 3 *
boonshen 0:a35c40f49345 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
boonshen 0:a35c40f49345 5 * of this software and associated documentation files (the "Software"), to deal
boonshen 0:a35c40f49345 6 * in the Software without restriction, including without limitation the rights
boonshen 0:a35c40f49345 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
boonshen 0:a35c40f49345 8 * copies of the Software, and to permit persons to whom the Software is
boonshen 0:a35c40f49345 9 * furnished to do so, subject to the following conditions:
boonshen 0:a35c40f49345 10 *
boonshen 0:a35c40f49345 11 * The above copyright notice and this permission notice shall be included in
boonshen 0:a35c40f49345 12 * all copies or substantial portions of the Software.
boonshen 0:a35c40f49345 13 *
boonshen 0:a35c40f49345 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
boonshen 0:a35c40f49345 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
boonshen 0:a35c40f49345 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
boonshen 0:a35c40f49345 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
boonshen 0:a35c40f49345 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
boonshen 0:a35c40f49345 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
boonshen 0:a35c40f49345 20 * SOFTWARE.
boonshen 0:a35c40f49345 21 */
boonshen 0:a35c40f49345 22 #include "rtos/Semaphore.h"
boonshen 0:a35c40f49345 23 #include "platform/mbed_assert.h"
boonshen 0:a35c40f49345 24
boonshen 0:a35c40f49345 25 #include <string.h>
boonshen 0:a35c40f49345 26
boonshen 0:a35c40f49345 27 namespace rtos {
boonshen 0:a35c40f49345 28
boonshen 0:a35c40f49345 29 Semaphore::Semaphore(int32_t count) {
boonshen 0:a35c40f49345 30 constructor(count, 0xffff);
boonshen 0:a35c40f49345 31 }
boonshen 0:a35c40f49345 32
boonshen 0:a35c40f49345 33 Semaphore::Semaphore(int32_t count, uint16_t max_count) {
boonshen 0:a35c40f49345 34 constructor(count, max_count);
boonshen 0:a35c40f49345 35 }
boonshen 0:a35c40f49345 36
boonshen 0:a35c40f49345 37 void Semaphore::constructor(int32_t count, uint16_t max_count) {
boonshen 0:a35c40f49345 38 memset(&_obj_mem, 0, sizeof(_obj_mem));
boonshen 0:a35c40f49345 39 memset(&_attr, 0, sizeof(_attr));
boonshen 0:a35c40f49345 40 _attr.cb_mem = &_obj_mem;
boonshen 0:a35c40f49345 41 _attr.cb_size = sizeof(_obj_mem);
boonshen 0:a35c40f49345 42 _id = osSemaphoreNew(max_count, count, &_attr);
boonshen 0:a35c40f49345 43 MBED_ASSERT(_id != NULL);
boonshen 0:a35c40f49345 44 }
boonshen 0:a35c40f49345 45
boonshen 0:a35c40f49345 46 int32_t Semaphore::wait(uint32_t millisec) {
boonshen 0:a35c40f49345 47 osStatus_t stat = osSemaphoreAcquire(_id, millisec);
boonshen 0:a35c40f49345 48 switch (stat) {
boonshen 0:a35c40f49345 49 case osOK:
boonshen 0:a35c40f49345 50 return osSemaphoreGetCount(_id) + 1;
boonshen 0:a35c40f49345 51 case osErrorTimeout:
boonshen 0:a35c40f49345 52 case osErrorResource:
boonshen 0:a35c40f49345 53 return 0;
boonshen 0:a35c40f49345 54 case osErrorParameter:
boonshen 0:a35c40f49345 55 default:
boonshen 0:a35c40f49345 56 return -1;
boonshen 0:a35c40f49345 57 }
boonshen 0:a35c40f49345 58 }
boonshen 0:a35c40f49345 59
boonshen 0:a35c40f49345 60 osStatus Semaphore::release(void) {
boonshen 0:a35c40f49345 61 return osSemaphoreRelease(_id);
boonshen 0:a35c40f49345 62 }
boonshen 0:a35c40f49345 63
boonshen 0:a35c40f49345 64 Semaphore::~Semaphore() {
boonshen 0:a35c40f49345 65 osSemaphoreDelete(_id);
boonshen 0:a35c40f49345 66 }
boonshen 0:a35c40f49345 67
boonshen 0:a35c40f49345 68 }