2018-08-17 14:37:11 +00:00
|
|
|
/*
|
2018-08-30 10:29:42 +00:00
|
|
|
* Copyright (c) , Arm Limited and affiliates.
|
2018-08-17 14:37:11 +00:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
Revise MbedCRC template
* Use compile-time detection of hardware CRC capability, so unneeded
code and tables do not go into the image.
* Add global JSON config option to allow choice between no tables,
16-entry tables or 256-entry tables for software CRC. Default set
to 16-entry, reducing ROM size from previous 256-entry.
* Allow manual override in template parameter to force software or
bitwise CRC for a particular instance.
* Micro-optimisations, particularly use of `RBIT` instruction and
optimising bitwise computation using inline assembler.
Incompatible changes:
* Remove special-case "POLY_32BIT_REV_ANSI" - users can use standard
POLY_32BIT_ANSI, which now uses the same 16-entry tables by default,
or can use hardware acceleration, which was disabled for
POLY_32BIT_REV_ANSI. MbedCRC<POLY_32BIT_ANSI, 32, CrcMode::TABLE> can
be used to force software like POLY_32BIT_REV_ANSI.
* The precomputed table for POLY_16BIT_IBM had errors - this has been
corrected, but software CRC results will be different from the previous
software calculation.
* < 8-bit CRC results are no longer are shifted up in the output value,
but placed in the lowest bits, like other sizes. This means that code
performing the SD command CRC will now need to use `(crc << 1) | 1`,
rather than `crc | 1`.
2019-09-24 13:49:04 +00:00
|
|
|
|
|
|
|
#ifndef MBED_CMSIS_H
|
|
|
|
#define MBED_CMSIS_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
static inline uint32_t __RBIT(uint32_t x)
|
|
|
|
{
|
|
|
|
x = ((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1);
|
|
|
|
x = ((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2);
|
|
|
|
x = ((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4);
|
|
|
|
x = ((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8);
|
|
|
|
x = (x >> 16) | (x << 16);
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|