diff options
| author | danicampora | 2015-02-22 17:31:26 +0100 |
|---|---|---|
| committer | danicampora | 2015-02-22 17:50:50 +0100 |
| commit | 33ddb566a7565b4fba4a68939d43bcdb5f132836 (patch) | |
| tree | bd348fd647ca26de8e05b18e411bcf7323a09a8c /cc3200/util | |
| parent | 5c047b97f2e41b51f8314f6ee06788b1d9246dbf (diff) | |
cc3200: Remove dependencies from FreeRTOS.
Use the simplelink wrappers instead. This is one step further
towards having a single module for the cc3200 and the cc3100.
Diffstat (limited to 'cc3200/util')
| -rw-r--r-- | cc3200/util/hash.c | 57 | ||||
| -rw-r--r-- | cc3200/util/hash.h | 26 |
2 files changed, 60 insertions, 23 deletions
diff --git a/cc3200/util/hash.c b/cc3200/util/hash.c index a7afdf9f2..acd147555 100644 --- a/cc3200/util/hash.c +++ b/cc3200/util/hash.c @@ -1,3 +1,29 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2015 Daniel Campora + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + #include "std.h" #include <stdint.h> #include <stdbool.h> @@ -11,34 +37,21 @@ #include "prcm.h" #include "shamd5.h" #include "hash.h" +#include "simplelink.h" -#ifdef USE_FREERTOS -#include "FreeRTOS.h" -#include "task.h" -#include "semphr.h" -#endif +static _SlLockObj_t hash_LockObj; -#ifdef USE_FREERTOS -static SemaphoreHandle_t xShamd5Semaphore = NULL; -#endif void HASH_Init (void) { // Enable the Data Hashing and Transform Engine MAP_PRCMPeripheralClkEnable(PRCM_DTHE, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK); -#ifdef USE_FREERTOS - vSemaphoreCreateBinary(xShamd5Semaphore); -#endif + sl_LockObjCreate(&hash_LockObj, "HashLock"); } - - void HASH_SHAMD5Start (uint32_t algo, uint32_t blocklen) { - -#ifdef USE_FREERTOS - xSemaphoreTake (xShamd5Semaphore, portMAX_DELAY); -#endif - + sl_LockObjLock (&hash_LockObj, SL_OS_WAIT_FOREVER); + // reset the perihperal before starting any new operation MAP_PRCMPeripheralReset(PRCM_DTHE); // wait until the context is ready @@ -62,11 +75,9 @@ void HASH_SHAMD5Update (uint8_t *data, uint32_t datalen) { } void HASH_SHAMD5Read (uint8_t *hash) { - // wait for the output to be ready. + // wait for the output to be ready while((HWREG(SHAMD5_BASE + SHAMD5_O_IRQSTATUS) & SHAMD5_INT_OUTPUT_READY) == 0); - // read the result. + // read the result MAP_SHAMD5ResultRead(SHAMD5_BASE, hash); -#ifdef USE_FREERTOS - xSemaphoreGive (xShamd5Semaphore); -#endif + sl_LockObjUnlock (&hash_LockObj); } diff --git a/cc3200/util/hash.h b/cc3200/util/hash.h index d13158461..edea1e3fc 100644 --- a/cc3200/util/hash.h +++ b/cc3200/util/hash.h @@ -1,3 +1,29 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2015 Daniel Campora + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + #ifndef HASH_H_ #define HASH_H_ |
