Subdirectory provided by Embedded Artists
Dependencies: DM_FATFileSystem DM_HttpServer DM_USBHost EthernetInterface USBDevice mbed-rpc mbed-rtos mbed-src
Dependents: lpc4088_displaymodule_hello_world_Sept_2018
Fork of DMSupport by
crc.cpp@41:ac490f69398f, 2018-10-04 (annotated)
- Committer:
- jmitc91516
- Date:
- Thu Oct 04 08:30:19 2018 +0000
- Revision:
- 41:ac490f69398f
- Parent:
- 29:b1ec19000e15
To demonstrate a problem with the dm_board_config.h file - the project will not build if it is in its normal place in the root directory, but builds OK if I copy it to the DMSupport subdirectory.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 11:dedcebcfc869 | 1 | /* |
embeddedartists | 11:dedcebcfc869 | 2 | * Copyright 2014 Embedded Artists AB |
embeddedartists | 11:dedcebcfc869 | 3 | * |
embeddedartists | 11:dedcebcfc869 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
embeddedartists | 11:dedcebcfc869 | 5 | * you may not use this file except in compliance with the License. |
embeddedartists | 11:dedcebcfc869 | 6 | * You may obtain a copy of the License at |
embeddedartists | 11:dedcebcfc869 | 7 | * |
embeddedartists | 11:dedcebcfc869 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
embeddedartists | 11:dedcebcfc869 | 9 | * |
embeddedartists | 11:dedcebcfc869 | 10 | * Unless required by applicable law or agreed to in writing, software |
embeddedartists | 11:dedcebcfc869 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
embeddedartists | 11:dedcebcfc869 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
embeddedartists | 11:dedcebcfc869 | 13 | * See the License for the specific language governing permissions and |
embeddedartists | 11:dedcebcfc869 | 14 | * limitations under the License. |
embeddedartists | 11:dedcebcfc869 | 15 | */ |
embeddedartists | 11:dedcebcfc869 | 16 | |
embeddedartists | 11:dedcebcfc869 | 17 | |
embeddedartists | 11:dedcebcfc869 | 18 | /****************************************************************************** |
embeddedartists | 11:dedcebcfc869 | 19 | * Includes |
embeddedartists | 11:dedcebcfc869 | 20 | *****************************************************************************/ |
embeddedartists | 11:dedcebcfc869 | 21 | |
embeddedartists | 11:dedcebcfc869 | 22 | #include "mbed.h" |
embeddedartists | 11:dedcebcfc869 | 23 | #include "crc.h" |
embeddedartists | 11:dedcebcfc869 | 24 | |
embeddedartists | 11:dedcebcfc869 | 25 | |
embeddedartists | 11:dedcebcfc869 | 26 | /****************************************************************************** |
embeddedartists | 11:dedcebcfc869 | 27 | * Defines and typedefs |
embeddedartists | 11:dedcebcfc869 | 28 | *****************************************************************************/ |
embeddedartists | 11:dedcebcfc869 | 29 | |
embeddedartists | 11:dedcebcfc869 | 30 | #define NUM_CRC_BUFF_ENTRIES (100) |
embeddedartists | 11:dedcebcfc869 | 31 | |
embeddedartists | 11:dedcebcfc869 | 32 | #define CRC32_INIT() do { LPC_CRC->MODE = 0x00000036; LPC_CRC->SEED = 0xffffffff; } while(0) |
embeddedartists | 11:dedcebcfc869 | 33 | |
embeddedartists | 11:dedcebcfc869 | 34 | #define CRC32_WRITE8(__val) LPC_CRC->WR_DATA_BYTE.DATA = (uint8_t)(__val) |
embeddedartists | 11:dedcebcfc869 | 35 | #define CRC32_WRITE16(__val) LPC_CRC->WR_DATA_WORD.DATA = (uint16_t)(__val) |
embeddedartists | 11:dedcebcfc869 | 36 | #define CRC32_WRITE32(__val) LPC_CRC->WR_DATA_DWORD.DATA = (__val) |
embeddedartists | 11:dedcebcfc869 | 37 | |
embeddedartists | 11:dedcebcfc869 | 38 | #define CRC32_SUM() LPC_CRC->SUM |
embeddedartists | 11:dedcebcfc869 | 39 | |
embeddedartists | 11:dedcebcfc869 | 40 | /****************************************************************************** |
embeddedartists | 11:dedcebcfc869 | 41 | * External global variables |
embeddedartists | 11:dedcebcfc869 | 42 | *****************************************************************************/ |
embeddedartists | 11:dedcebcfc869 | 43 | |
embeddedartists | 11:dedcebcfc869 | 44 | /****************************************************************************** |
embeddedartists | 11:dedcebcfc869 | 45 | * Local variables |
embeddedartists | 11:dedcebcfc869 | 46 | *****************************************************************************/ |
embeddedartists | 11:dedcebcfc869 | 47 | |
embeddedartists | 11:dedcebcfc869 | 48 | /****************************************************************************** |
embeddedartists | 11:dedcebcfc869 | 49 | * Local Functions |
embeddedartists | 11:dedcebcfc869 | 50 | *****************************************************************************/ |
embeddedartists | 11:dedcebcfc869 | 51 | |
embeddedartists | 11:dedcebcfc869 | 52 | |
embeddedartists | 11:dedcebcfc869 | 53 | /****************************************************************************** |
embeddedartists | 11:dedcebcfc869 | 54 | * Public Functions |
embeddedartists | 11:dedcebcfc869 | 55 | *****************************************************************************/ |
embeddedartists | 11:dedcebcfc869 | 56 | |
embeddedartists | 11:dedcebcfc869 | 57 | uint32_t crc_File(FILE* f) |
embeddedartists | 11:dedcebcfc869 | 58 | { |
embeddedartists | 11:dedcebcfc869 | 59 | uint32_t* buff = (uint32_t*)malloc(sizeof(uint32_t)*NUM_CRC_BUFF_ENTRIES); |
embeddedartists | 11:dedcebcfc869 | 60 | if (buff != NULL) { |
embeddedartists | 11:dedcebcfc869 | 61 | CRC32_INIT(); |
embeddedartists | 11:dedcebcfc869 | 62 | fseek(f, 0, SEEK_SET); |
embeddedartists | 11:dedcebcfc869 | 63 | memset(buff, 0, sizeof(uint32_t)*NUM_CRC_BUFF_ENTRIES); |
embeddedartists | 11:dedcebcfc869 | 64 | int numRead = fread(buff, sizeof(uint32_t), NUM_CRC_BUFF_ENTRIES, f); |
embeddedartists | 11:dedcebcfc869 | 65 | while (numRead > 0) { |
embeddedartists | 11:dedcebcfc869 | 66 | for (int i = 0; i < numRead; i++) { |
embeddedartists | 11:dedcebcfc869 | 67 | CRC32_WRITE32(buff[i]); |
embeddedartists | 11:dedcebcfc869 | 68 | } |
embeddedartists | 11:dedcebcfc869 | 69 | numRead = fread(buff, sizeof(uint32_t), NUM_CRC_BUFF_ENTRIES, f); |
embeddedartists | 11:dedcebcfc869 | 70 | } |
embeddedartists | 11:dedcebcfc869 | 71 | free(buff); |
embeddedartists | 11:dedcebcfc869 | 72 | return CRC32_SUM(); |
embeddedartists | 11:dedcebcfc869 | 73 | } |
embeddedartists | 11:dedcebcfc869 | 74 | return 0; |
embeddedartists | 11:dedcebcfc869 | 75 | } |
embeddedartists | 11:dedcebcfc869 | 76 | |
embeddedartists | 11:dedcebcfc869 | 77 | uint32_t crc_Buffer(const uint32_t* data, uint32_t size) |
embeddedartists | 11:dedcebcfc869 | 78 | { |
embeddedartists | 11:dedcebcfc869 | 79 | CRC32_INIT(); |
embeddedartists | 29:b1ec19000e15 | 80 | for (uint32_t i = 0; i < size; i++) { |
embeddedartists | 11:dedcebcfc869 | 81 | CRC32_WRITE32(data[i]); |
embeddedartists | 11:dedcebcfc869 | 82 | } |
embeddedartists | 11:dedcebcfc869 | 83 | return CRC32_SUM(); |
embeddedartists | 11:dedcebcfc869 | 84 | } |
embeddedartists | 11:dedcebcfc869 | 85 |