Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
src/lut.cpp
- Committer:
- mfwic
- Date:
- 2018-12-07
- Revision:
- 9:816b9a4e4f21
- Parent:
- 7:860b3a8275cb
- Child:
- 11:01dcfb29fbc4
File content as of revision 9:816b9a4e4f21:
//------------------------------------------------------------------------------- // // Treehouse Designs Inc. // Colorado Springs, Colorado // // Copyright (c) 2016 by Treehouse Designs Inc. // Copyright (c) 2018 by Agility Power Systems Inc. // // This code is the property of Treehouse Designs, Inc. (Treehouse) and // Agility Power Systems Inc. (Agility) and may not be redistributed // in any form without prior written permission from // both copyright holders, Treehouse and Agility. // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // //------------------------------------------------------------------------------- // // REVISION HISTORY: // // $Author: $ // $Rev: $ // $Date: $ // $URL: $ // //------------------------------------------------------------------------------- #include "mbed.h" #include "stdint.h" #include "globals.h" #include "lut.h" //unsigned int binCode[6]; /* #define MAX_LUT_ENTRIES 1024 uint8_t binC[MAX_LUT_ENTRIES] { 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19}; uint8_t thermC[MAX_LUT_ENTRIES]{ 0, 0, 1, 1, 2, 2, 3, 3, 4, 5}; */ #include "lut_data_en_v1.h" #include "lut_data_slot_v1.h" /******************************************************************************* dec2bin_fix - Converts decimal to binary with fixed width as specified. *******************************************************************************/ void dec2bin_fix(unsigned int dec, unsigned int n){ int k; for (int c = 5; c >= 0; c--){ k = dec >> c; if (k & 1) binCode[n] = 1; else binCode[n] = 0; n--; } } /******************************************************************************* dec2therm_fix - Converts decimal to thermometer code with fixed width as specified. *******************************************************************************/ void dec2therm_fix(unsigned int dec, unsigned int n){ for (int i = 0; i <= n; i++){ thermCode[i] = 0; } for (int i = 0; i <= dec; i++){ thermCode[i] = 1; } } /******************************************************************************* getLUTcode - gets output codes from LUT using row reference. *******************************************************************************/ void getLUTcode(unsigned short row){ dec2bin_fix(binC[row], (unsigned int)WEIGHT_BIN_WIDTH); dec2therm_fix(thermC[row], (unsigned int)BOARDS_THERMCODE_WIDTH); } /******************************************************************************* getLUT_binCode - gets output codes from LUT using row reference. *******************************************************************************/ unsigned int getLUT_binCode(unsigned short row){ return binC[row]; } /******************************************************************************* getLUT_binCode - gets output codes from LUT using row reference. *******************************************************************************/ unsigned int getLUT_thermCode(unsigned short row){ return thermC[row]; }