mirror of
https://github.com/markqvist/OpenModem.git
synced 2024-12-29 01:16:17 -05:00
Cleanup
This commit is contained in:
parent
7b5495b767
commit
35a92e167e
@ -353,8 +353,6 @@ void mp1Send(MP1 *mp1, void *_buffer, size_t length) {
|
||||
// Get the transmit data buffer
|
||||
uint8_t *buffer = (uint8_t *)_buffer;
|
||||
|
||||
uint8_t *compressed = (uint8_t *)compressionBuffer;
|
||||
|
||||
// Initialize checksum to zero
|
||||
mp1->checksum_out = MP1_CHECKSUM_INIT;
|
||||
|
||||
|
@ -1,102 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
|
||||
* Copyright 1999 Bernie Innocenti <bernie@codewiz.org>
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief CRC table and support routines
|
||||
*
|
||||
* \author Bernie Innocenti <bernie@codewiz.org>
|
||||
*/
|
||||
|
||||
#include "crc.h"
|
||||
|
||||
/*
|
||||
* The boot on AVR cpu is placed at the end of flash memory, but the avr
|
||||
* address memory by byte and the pointers are 16bits long, so we are able
|
||||
* to address 64Kbyte memory max. For this reason we can't read the crctab
|
||||
* from flash, because it is placed at the end of memory. This is true every
|
||||
* time we have an AVR cpu with more that 64Kbyte of flash. To fix this problem
|
||||
* we let the compiler copy the table in RAM at startup. Obviously this solution
|
||||
* is not efficent, but for now this is the only way.
|
||||
*/
|
||||
#if CPU_HARVARD && !(defined(ARCH_BOOT) && (ARCH & ARCH_BOOT))
|
||||
#define CRC_TABLE const uint16_t PROGMEM crc16tab[256]
|
||||
#else
|
||||
#define CRC_TABLE const uint16_t crc16tab[256]
|
||||
#endif
|
||||
|
||||
/**
|
||||
* crctab calculated by Mark G. Mendel, Network Systems Corporation
|
||||
*/
|
||||
CRC_TABLE = {
|
||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
|
||||
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
|
||||
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
||||
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
|
||||
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
|
||||
0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
|
||||
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
|
||||
0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
|
||||
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
|
||||
0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
|
||||
0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
|
||||
0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
|
||||
0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
|
||||
0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
|
||||
0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
|
||||
0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
|
||||
0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
|
||||
0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
|
||||
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
|
||||
0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
|
||||
0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
|
||||
0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
|
||||
0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
|
||||
0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
|
||||
0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
|
||||
0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
|
||||
0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
|
||||
0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
|
||||
0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
|
||||
0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
|
||||
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
|
||||
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
|
||||
};
|
||||
|
||||
uint16_t crc16(uint16_t crc, const void *buffer, size_t len)
|
||||
{
|
||||
const unsigned char *buf = (const unsigned char *)buffer;
|
||||
while(len--)
|
||||
crc = UPDCRC16(*buf++, crc);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
@ -1,115 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
|
||||
* Copyright 1999 Bernie Innocenti <bernie@codewiz.org>
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Cyclic Redundancy Check 16 (CRC). This algorithm is the one used by the XMODEM protocol.
|
||||
*
|
||||
* \note This algorithm is incompatible with the CCITT-CRC16.
|
||||
*
|
||||
* This code is based on the article Copyright 1986 Stephen Satchell.
|
||||
*
|
||||
* Programmers may incorporate any or all code into their programs,
|
||||
* giving proper credit within the source. Publication of the
|
||||
* source routines is permitted so long as proper credit is given
|
||||
* to Stephen Satchell, Satchell Evaluations and Chuck Forsberg,
|
||||
* Omen Technology.
|
||||
*
|
||||
* \author Bernie Innocenti <bernie@codewiz.org>
|
||||
*
|
||||
* $WIZ$ module_name = "crc16"
|
||||
*/
|
||||
|
||||
#ifndef ALGO_CRC_H
|
||||
#define ALGO_CRC_H
|
||||
|
||||
#include "cfg/cfg_arch.h"
|
||||
|
||||
#include <cfg/compiler.h>
|
||||
#include <cpu/pgm.h>
|
||||
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
/* CRC table */
|
||||
extern const uint16_t crc16tab[256];
|
||||
|
||||
|
||||
/**
|
||||
* \brief Compute the updated CRC16 value for one octet (macro version)
|
||||
*
|
||||
* \note This version is only intended for old/broken compilers.
|
||||
* Use the inline function in new code.
|
||||
*
|
||||
* \param c New octet (range 0-255)
|
||||
* \param oldcrc Previous CRC16 value (referenced twice, beware of side effects)
|
||||
*/
|
||||
#if CPU_HARVARD && !(defined(ARCH_BOOT) && (ARCH & ARCH_BOOT))
|
||||
#define UPDCRC16(c, oldcrc) (pgm_read_uint16_t(&crc16tab[((oldcrc) >> 8) ^ ((unsigned char)(c))]) ^ ((oldcrc) << 8))
|
||||
#else
|
||||
#define UPDCRC16(c, oldcrc) ((crc16tab[((oldcrc) >> 8) ^ ((unsigned char)(c))]) ^ ((oldcrc) << 8))
|
||||
#endif
|
||||
|
||||
/** CRC-16 init value */
|
||||
#define CRC16_INIT_VAL ((uint16_t)0)
|
||||
|
||||
#ifdef INLINE
|
||||
/**
|
||||
* \brief Compute the updated CRC16 value for one octet (inline version)
|
||||
*/
|
||||
INLINE uint16_t updcrc16(uint8_t c, uint16_t oldcrc)
|
||||
{
|
||||
#if CPU_HARVARD && !(defined(ARCH_BOOT) && (ARCH & ARCH_BOOT))
|
||||
return pgm_read_uint16_t(&crc16tab[(oldcrc >> 8) ^ c]) ^ (oldcrc << 8);
|
||||
#else
|
||||
return crc16tab[(oldcrc >> 8) ^ c] ^ (oldcrc << 8);
|
||||
#endif
|
||||
}
|
||||
#endif // INLINE
|
||||
|
||||
|
||||
/**
|
||||
* This function implements the CRC 16 calculation on a buffer.
|
||||
*
|
||||
* \param crc Current CRC16 value.
|
||||
* \param buf The buffer to perform CRC calculation on.
|
||||
* \param len The length of the Buffer.
|
||||
*
|
||||
* \return The updated CRC16 value.
|
||||
*/
|
||||
extern uint16_t crc16(uint16_t crc, const void *buf, size_t len);
|
||||
|
||||
int crc_testSetup(void);
|
||||
int crc_testRun(void);
|
||||
int crc_testTearDown(void);
|
||||
|
||||
EXTERN_C_END
|
||||
|
||||
#endif /* ALGO_CRC_H */
|
@ -1,83 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2009 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief CRC-CCITT table and support routines
|
||||
*
|
||||
* \author Francesco Sacchi <batt@develer.com>
|
||||
*/
|
||||
|
||||
#include "crc_ccitt.h"
|
||||
|
||||
const uint16_t PROGMEM crc_ccitt_tab[256] = {
|
||||
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
||||
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
||||
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
||||
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
|
||||
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
|
||||
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
|
||||
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
|
||||
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
|
||||
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
|
||||
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
|
||||
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
|
||||
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
|
||||
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
|
||||
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
|
||||
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
|
||||
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
|
||||
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
|
||||
0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
|
||||
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
|
||||
0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
|
||||
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
|
||||
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
|
||||
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
|
||||
0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
|
||||
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
|
||||
0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
|
||||
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
|
||||
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
|
||||
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
|
||||
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
|
||||
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
||||
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78,
|
||||
};
|
||||
|
||||
uint16_t crc_ccitt(uint16_t crc, const void *buffer, size_t len)
|
||||
{
|
||||
const unsigned char *buf = (const unsigned char *)buffer;
|
||||
while (len--)
|
||||
crc = updcrc_ccitt(*buf++, crc);
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
@ -1,78 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2009 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief CCITT Cyclic Redundancy Check (CRC-CCITT).
|
||||
*
|
||||
* \note This algorithm is incompatible with the CRC16.
|
||||
*
|
||||
* \author Francesco Sacchi <batt@develer.com>
|
||||
*
|
||||
* $WIZ$ module_name = "crc-ccitt"
|
||||
*/
|
||||
|
||||
#ifndef ALGO_CRC_CCITT_H
|
||||
#define ALGO_CRC_CCITT_H
|
||||
|
||||
#include <cfg/compiler.h>
|
||||
#include <cpu/pgm.h>
|
||||
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
/* CRC table */
|
||||
extern const uint16_t crc_ccitt_tab[256];
|
||||
|
||||
/**
|
||||
* \brief Compute the updated CRC-CCITT value for one octet (inline version)
|
||||
*/
|
||||
INLINE uint16_t updcrc_ccitt(uint8_t c, uint16_t oldcrc)
|
||||
{
|
||||
return (oldcrc >> 8) ^ pgm_read16(&crc_ccitt_tab[(oldcrc ^ c) & 0xff]);
|
||||
}
|
||||
|
||||
/** CRC-CCITT init value */
|
||||
#define CRC_CCITT_INIT_VAL ((uint16_t)0xFFFF)
|
||||
|
||||
|
||||
/**
|
||||
* This function implements the CRC-CCITT calculation on a buffer.
|
||||
*
|
||||
* \param crc Current CRC-CCITT value.
|
||||
* \param buf The buffer to perform CRC calculation on.
|
||||
* \param len The length of the Buffer.
|
||||
*
|
||||
* \return The updated CRC-CCITT value.
|
||||
*/
|
||||
extern uint16_t crc_ccitt(uint16_t crc, const void *buf, size_t len);
|
||||
|
||||
EXTERN_C_END
|
||||
|
||||
#endif /* ALGO_CRC_CCITT_H */
|
@ -1,75 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
|
||||
* Copyright 1999 Bernie Innocenti <bernie@codewiz.org>
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief CRC-CCITT table and support routines
|
||||
*
|
||||
* \author Francesco Sacchi <batt@develer.com>
|
||||
*/
|
||||
|
||||
#include "crc_ccitt.h"
|
||||
#include "crc.h"
|
||||
|
||||
#include <cfg/debug.h>
|
||||
#include <cfg/test.h>
|
||||
|
||||
|
||||
int crc_testSetup(void)
|
||||
{
|
||||
kdbg_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int crc_testTearDown(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int crc_testRun(void)
|
||||
{
|
||||
char vector[9] = "123456789";
|
||||
|
||||
uint16_t crc = CRC_CCITT_INIT_VAL;
|
||||
|
||||
crc = crc_ccitt(crc, vector, sizeof(vector));
|
||||
kprintf("crc_ccitt [%04X]\n", crc);
|
||||
ASSERT(crc == 0x6F91);
|
||||
|
||||
crc = CRC16_INIT_VAL;
|
||||
crc = crc16(crc, vector, sizeof(vector));
|
||||
kprintf("crc16 [%04X]\n", crc);
|
||||
ASSERT(crc == 0x31C3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST_MAIN(crc);
|
@ -1,336 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2007 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief MD2 Message-Digest algorithm.
|
||||
*
|
||||
* The MD2 algorithm work with a constant array of 256 permutationt
|
||||
* defined in RFC1319. If you don't want to use a standard array of
|
||||
* permutatione you can use a md2_perm() function that generate an
|
||||
* array of 256 "casual" permutation. To swich from a standard array
|
||||
* to md2_perm function you must chanche CONFIG_MD2_STD_PERM defined in
|
||||
* appconfig.h.
|
||||
* If you need to store array in program memory you must define
|
||||
* a macro _PROGMEM (for more info see cpu/pgm.h).
|
||||
*
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#include "md2.h"
|
||||
|
||||
#include <string.h> //memset(), memcpy();
|
||||
#include <cfg/compiler.h>
|
||||
#include <cfg/debug.h> //ASSERT()
|
||||
#include <cfg/macros.h> //MIN(), countof(), ROTR();
|
||||
#include <cpu/pgm.h>
|
||||
|
||||
|
||||
#if CONFIG_MD2_STD_PERM
|
||||
/*
|
||||
* Official array of 256 byte pemutation contructed from digits of pi, defined
|
||||
* in the RFC 1319.
|
||||
*/
|
||||
static const uint8_t PROGMEM md2_perm[256] =
|
||||
{
|
||||
41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6,
|
||||
19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188,
|
||||
76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24,
|
||||
138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251,
|
||||
245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63,
|
||||
148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50,
|
||||
39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165,
|
||||
181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210,
|
||||
150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157,
|
||||
112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27,
|
||||
96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15,
|
||||
85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197,
|
||||
234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65,
|
||||
129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123,
|
||||
8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233,
|
||||
203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228,
|
||||
166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237,
|
||||
31, 26, 219, 153, 141, 51, 159, 17, 131, 20
|
||||
};
|
||||
|
||||
#define MD2_PERM(x) pgm_read8(&md2_perm[x])
|
||||
#else
|
||||
/**
|
||||
* Md2_perm() function generate an array of 256 "casual" permutation.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Costant define for computing an array of 256 "casual" permutation.
|
||||
* \{
|
||||
*/
|
||||
#define K1 5
|
||||
#define K2 3
|
||||
#define R 2
|
||||
#define X 172
|
||||
/*\}*/
|
||||
|
||||
static uint8_t md2_perm(uint8_t i)
|
||||
{
|
||||
|
||||
i = i * K1;
|
||||
i = ROTR(i, R);
|
||||
i ^= X;
|
||||
i = i * K2;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
#define MD2_PERM(x) md2_perm(x)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Pad function. Put len_pad unsigned char in
|
||||
* input block.
|
||||
*/
|
||||
static void md2_pad(void *_block, size_t len_pad)
|
||||
{
|
||||
uint8_t *block;
|
||||
|
||||
block = (uint8_t *)_block;
|
||||
|
||||
ASSERT(len_pad <= CONFIG_MD2_BLOCK_LEN);
|
||||
|
||||
/*
|
||||
* Fill input block with len_pad char.
|
||||
*/
|
||||
memset(block, len_pad, len_pad);
|
||||
|
||||
}
|
||||
|
||||
static void md2_compute(void *_state, void *_checksum, void *_block)
|
||||
{
|
||||
int i = 0;
|
||||
uint16_t t = 0;
|
||||
uint8_t compute_array[COMPUTE_ARRAY_LEN];
|
||||
uint8_t *state;
|
||||
uint8_t *checksum;
|
||||
uint8_t *block;
|
||||
|
||||
state = (uint8_t *)_state;
|
||||
checksum = (uint8_t *)_checksum;
|
||||
block = (uint8_t *)_block;
|
||||
|
||||
/*
|
||||
* Copy state and checksum context in compute array.
|
||||
*/
|
||||
memcpy(compute_array, state, CONFIG_MD2_BLOCK_LEN);
|
||||
memcpy(compute_array + CONFIG_MD2_BLOCK_LEN, block, CONFIG_MD2_BLOCK_LEN);
|
||||
|
||||
/*
|
||||
* Fill compute array with state XOR block
|
||||
*/
|
||||
for(i = 0; i < CONFIG_MD2_BLOCK_LEN; i++)
|
||||
compute_array[i + (CONFIG_MD2_BLOCK_LEN * 2)] = state[i] ^ block[i];
|
||||
|
||||
/*
|
||||
* Encryt block.
|
||||
*/
|
||||
for(i = 0; i < NUM_COMPUTE_ROUNDS; i++)
|
||||
{
|
||||
for(int j = 0; j < COMPUTE_ARRAY_LEN; j++)
|
||||
{
|
||||
compute_array[j] ^= MD2_PERM(t);
|
||||
t = compute_array[j];
|
||||
}
|
||||
|
||||
t = (t + i) & 0xff; //modulo 256.
|
||||
}
|
||||
/*
|
||||
* Update checksum.
|
||||
*/
|
||||
t = checksum[CONFIG_MD2_BLOCK_LEN - 1];
|
||||
|
||||
for(i = 0; i < CONFIG_MD2_BLOCK_LEN; i++)
|
||||
{
|
||||
checksum[i] ^= MD2_PERM(block[i] ^ t);
|
||||
t = checksum[i];
|
||||
}
|
||||
|
||||
/*
|
||||
* Update state and clean compute array.
|
||||
*/
|
||||
memcpy(state, compute_array, CONFIG_MD2_BLOCK_LEN);
|
||||
memset(compute_array, 0, sizeof(compute_array));
|
||||
}
|
||||
|
||||
/**
|
||||
* Algorithm initialization.
|
||||
*
|
||||
* \param context empty context.
|
||||
*/
|
||||
void md2_init(Md2Context *context)
|
||||
{
|
||||
|
||||
memset(context, 0, sizeof(Md2Context));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update block.
|
||||
*/
|
||||
void md2_update(Md2Context *context, const void *_block_in, size_t block_len)
|
||||
{
|
||||
|
||||
const uint8_t *block_in;
|
||||
size_t cpy_len;
|
||||
|
||||
|
||||
block_in = (const uint8_t *)_block_in;
|
||||
|
||||
while(block_len > 0)
|
||||
{
|
||||
/*
|
||||
* Choose a number of block that fill input context buffer.
|
||||
*/
|
||||
cpy_len = MIN(block_len, CONFIG_MD2_BLOCK_LEN - context->counter);
|
||||
|
||||
|
||||
/*
|
||||
* Copy in the buffer input block.
|
||||
*/
|
||||
memcpy(&context->buffer[context->counter], block_in, cpy_len);
|
||||
|
||||
/*
|
||||
* Update a context counter, input block length and remaning
|
||||
* context buffer block lenght.
|
||||
*/
|
||||
context->counter += cpy_len;
|
||||
block_len -= cpy_len;
|
||||
block_in += cpy_len;
|
||||
|
||||
/*
|
||||
* If buffer is full, compute it.
|
||||
*/
|
||||
if (context->counter >= CONFIG_MD2_BLOCK_LEN)
|
||||
{
|
||||
md2_compute(context->state, context->checksum, context->buffer);
|
||||
context->counter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* Ends an MD2 message digest operation.
|
||||
* This fuction take an context and return a pointer
|
||||
* to context state.
|
||||
*
|
||||
* \param context in input.
|
||||
* \return a pointer to context state (message digest).
|
||||
*/
|
||||
uint8_t *md2_end(Md2Context *context)
|
||||
{
|
||||
|
||||
uint8_t buf[CONFIG_MD2_BLOCK_LEN];
|
||||
|
||||
/*
|
||||
* Fill remaning empty context buffer.
|
||||
*/
|
||||
md2_pad(buf, CONFIG_MD2_BLOCK_LEN - context->counter);
|
||||
|
||||
/*
|
||||
* Update context buffer and compute it.
|
||||
*/
|
||||
md2_update(context, buf, CONFIG_MD2_BLOCK_LEN - context->counter);
|
||||
|
||||
/*
|
||||
* Add context checksum to message input.
|
||||
*/
|
||||
md2_update(context, context->checksum, CONFIG_MD2_BLOCK_LEN);
|
||||
|
||||
|
||||
return context->state; //return a pointer to message digest.
|
||||
}
|
||||
/**
|
||||
* MD2 test fuction.
|
||||
* This function test MD2 algorithm with a standard string specified
|
||||
* in RFC 1319.
|
||||
*
|
||||
* \note This test work with official array of 256 byte pemutation
|
||||
* contructed from digits of pi, defined in the RFC 1319.
|
||||
*
|
||||
*/
|
||||
bool md2_test(void)
|
||||
{
|
||||
|
||||
Md2Context context;
|
||||
|
||||
const char *test[] =
|
||||
{
|
||||
"",
|
||||
"message digest",
|
||||
"abcdefghijklmnopqrstuvwxyz",
|
||||
"12345678901234567890123456789012345678901234567890123456789012345678901234567890"
|
||||
};
|
||||
|
||||
|
||||
const char *result[] = {
|
||||
"\x83\x50\xe5\xa3\xe2\x4c\x15\x3d\xf2\x27\x5c\x9f\x80\x69\x27\x73",
|
||||
"\xab\x4f\x49\x6b\xfb\x2a\x53\x0b\x21\x9f\xf3\x30\x31\xfe\x06\xb0",
|
||||
"\x4e\x8d\xdf\xf3\x65\x02\x92\xab\x5a\x41\x08\xc3\xaa\x47\x94\x0b",
|
||||
"\xd5\x97\x6f\x79\xd8\x3d\x3a\x0d\xc9\x80\x6c\x3c\x66\xf3\xef\xd8",
|
||||
};
|
||||
|
||||
|
||||
for (size_t i = 0; i < countof(test); i++)
|
||||
{
|
||||
md2_init(&context);
|
||||
md2_update(&context, test[i], strlen(test[i]));
|
||||
|
||||
if(memcmp(result[i], md2_end(&context), MD2_DIGEST_LEN))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
#include <stdio.h>
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
|
||||
if(md2_test())
|
||||
printf("MD2 algorithm work well!\n");
|
||||
else
|
||||
printf("MD2 algorithm doesn't work well.\n");
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,74 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2007 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief MD2 Message-Digest algorithm.
|
||||
*
|
||||
* The algorithm takes as input a message of arbitrary length and produces
|
||||
* as output a 128-bit message digest of the input.
|
||||
* It is conjectured that it is computationally infeasible to produce
|
||||
* two messages having the same message digest, or to produce any
|
||||
* message having a given prespecified target message digest.
|
||||
*
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
* $WIZ$ module_name = "md2"
|
||||
* $WIZ$ module_configuration = "bertos/cfg/cfg_md2.h"
|
||||
*/
|
||||
|
||||
#ifndef ALGO_MD2_H
|
||||
#define ALGO_MD2_H
|
||||
|
||||
#include "cfg/cfg_md2.h"
|
||||
#include <cfg/compiler.h>
|
||||
|
||||
#define NUM_COMPUTE_ROUNDS 18 ///< Number of compute rounds.
|
||||
#define COMPUTE_ARRAY_LEN CONFIG_MD2_BLOCK_LEN * 3 ///< Lenght of compute array.
|
||||
#define MD2_DIGEST_LEN CONFIG_MD2_BLOCK_LEN
|
||||
/**
|
||||
* Context for MD2 computation.
|
||||
*/
|
||||
typedef struct Md2Context
|
||||
{
|
||||
uint8_t buffer[CONFIG_MD2_BLOCK_LEN]; ///< Input buffer.
|
||||
uint8_t state[CONFIG_MD2_BLOCK_LEN]; ///< Current state buffer.
|
||||
uint8_t checksum[CONFIG_MD2_BLOCK_LEN]; ///< Checksum.
|
||||
size_t counter; ///< Counter of remaining bytes.
|
||||
|
||||
} Md2Context;
|
||||
|
||||
void md2_init(Md2Context *context);
|
||||
void md2_update(Md2Context *context, const void *block_in, size_t block_len);
|
||||
uint8_t *md2_end(Md2Context *context);
|
||||
bool md2_test(void);
|
||||
|
||||
#endif /* ALGO_MD2_H */
|
@ -1,41 +0,0 @@
|
||||
#warning revise me!
|
||||
|
||||
|
||||
/**
|
||||
* DECLARE_SMEAN(temperature, uint8_t, uint16_t);
|
||||
* for (i = 0; i < TEMP_MEANS; ++i)
|
||||
* SMEAN_ADD(temperature, adc_get(), TEMP_MEANS);
|
||||
* printf("mean temperature = %d\n", SMEAN_GET(temperature));
|
||||
*/
|
||||
|
||||
/**
|
||||
* Instantiate a mean instance
|
||||
*/
|
||||
#define DECLARE_SMEAN(name, Type, SumType) \
|
||||
struct { \
|
||||
SumType sum; \
|
||||
Type result; \
|
||||
int count; \
|
||||
} name = { 0, 0, 0 }
|
||||
|
||||
/**
|
||||
* Insert a new sample into the mean.
|
||||
*
|
||||
* \note \a mean and \a max_samples are evaluated multiple times
|
||||
*/
|
||||
#define SMEAN_ADD(mean, sample, max_samples) \
|
||||
do { \
|
||||
(mean).sum += (sample); \
|
||||
if ((mean).count++ >= (max_samples)) \
|
||||
{ \
|
||||
(mean).result = (mean).sum / (max_samples); \
|
||||
(mean).sum = 0; \
|
||||
(mean).count = 0; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Return current mean value.
|
||||
*/
|
||||
#define SMEAN_GET(mean) ((mean).result)
|
||||
|
@ -1,115 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* -->
|
||||
*
|
||||
*
|
||||
* \brief Proportional, integral, derivative controller (PID controller) (implementation)
|
||||
*
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#include "pid_control.h"
|
||||
|
||||
#include "cfg/cfg_pid.h"
|
||||
|
||||
// Define logging setting (for cfg/log.h module).
|
||||
#define LOG_LEVEL PID_LOG_LEVEL
|
||||
#define LOG_VERBOSITY PID_LOG_FORMAT
|
||||
|
||||
#include <cfg/log.h>
|
||||
#include <cfg/debug.h>
|
||||
|
||||
/**
|
||||
* Compute next value for reaching \a target point.
|
||||
*/
|
||||
piddata_t pid_control_update(PidContext *pid_ctx, piddata_t target, piddata_t curr_pos)
|
||||
{
|
||||
piddata_t P;
|
||||
piddata_t I;
|
||||
piddata_t D;
|
||||
piddata_t err;
|
||||
|
||||
//Compute current error.
|
||||
err = target - curr_pos;
|
||||
|
||||
/*
|
||||
* Compute Proportional contribute
|
||||
*/
|
||||
P = err * pid_ctx->cfg->kp;
|
||||
|
||||
//Update integral state error
|
||||
pid_ctx->i_state += err;
|
||||
|
||||
//Clamp integral state between i_min and i_max
|
||||
pid_ctx->i_state = MINMAX(pid_ctx->cfg->i_min, pid_ctx->i_state, pid_ctx->cfg->i_max);
|
||||
|
||||
/*
|
||||
* Compute Integral contribute
|
||||
*
|
||||
* note: for computing the integral contribute we use a sample period in seconds
|
||||
* and so we divide sample_period in microsenconds for 1000.
|
||||
*/
|
||||
I = pid_ctx->i_state * pid_ctx->cfg->ki * ((piddata_t)pid_ctx->cfg->sample_period / 1000);
|
||||
|
||||
|
||||
/*
|
||||
* Compute derivative contribute
|
||||
*/
|
||||
D = (err - pid_ctx->prev_err) * pid_ctx->cfg->kd / ((piddata_t)pid_ctx->cfg->sample_period / 1000);
|
||||
|
||||
|
||||
LOG_INFO("curr_pos[%lf],tgt[%lf],err[%f],P[%f],I[%f],D[%f]", curr_pos, target, err, P, I, D);
|
||||
|
||||
|
||||
//Store the last error value
|
||||
pid_ctx->prev_err = err;
|
||||
piddata_t pid = MINMAX(pid_ctx->cfg->out_min, (P + I + D), pid_ctx->cfg->out_max);
|
||||
|
||||
LOG_INFO("pid[%lf]",pid);
|
||||
|
||||
//Clamp out between out_min and out_max
|
||||
return pid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init PID control.
|
||||
*/
|
||||
void pid_control_init(PidContext *pid_ctx, const PidCfg *pid_cfg)
|
||||
{
|
||||
/*
|
||||
* Init all values of pid control struct
|
||||
*/
|
||||
pid_ctx->cfg = pid_cfg;
|
||||
|
||||
pid_control_reset(pid_ctx);
|
||||
|
||||
}
|
||||
|
@ -1,115 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* -->
|
||||
*
|
||||
*
|
||||
* \brief Proportional, integral, derivative controller (PID controller).
|
||||
*
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
* $WIZ$ module_name = "pid_control"
|
||||
* $WIZ$ module_depends = "timer"
|
||||
*/
|
||||
|
||||
#ifndef ALGO_PID_CONTROL_H
|
||||
#define ALGO_PID_CONTROL_H
|
||||
|
||||
#include <drv/timer.h>
|
||||
|
||||
/**
|
||||
* Data type for pid coefficient.
|
||||
*/
|
||||
typedef float pidk_t;
|
||||
typedef float piddata_t;
|
||||
|
||||
/**
|
||||
* PID context structure.
|
||||
*/
|
||||
typedef struct PidCfg
|
||||
{
|
||||
pidk_t kp; ///< Proportional term of PID control method (Gain).
|
||||
pidk_t ki; ///< Integral term of PID control method (Integral Gain).
|
||||
pidk_t kd; ///< Derivative of PID control method (Derivative Gain).
|
||||
|
||||
piddata_t i_max; ///< Max value of integral term.
|
||||
piddata_t i_min; ///< Min value of integral term.
|
||||
|
||||
piddata_t out_max; ///< Man value of output.
|
||||
piddata_t out_min; ///< Min value of output.
|
||||
|
||||
mtime_t sample_period; ///< Sample period in milliseconds.
|
||||
|
||||
} PidCfg;
|
||||
|
||||
|
||||
/**
|
||||
* PID context structure.
|
||||
*/
|
||||
typedef struct PidContext
|
||||
{
|
||||
const PidCfg *cfg;
|
||||
|
||||
piddata_t prev_err; ///< Previous error.
|
||||
piddata_t i_state; ///< Integrator state (sum of all the preceding errors).
|
||||
|
||||
} PidContext;
|
||||
|
||||
/**
|
||||
* Set Kp, Ki, Kd constants of PID control.
|
||||
*/
|
||||
INLINE void pid_control_setPid(PidCfg *pid_cfg, pidk_t kp, pidk_t ki, pidk_t kd)
|
||||
{
|
||||
pid_cfg->kp = kp;
|
||||
pid_cfg->ki = ki;
|
||||
pid_cfg->kd = kd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sample period for PID control.
|
||||
*/
|
||||
INLINE void pid_control_setPeriod(PidCfg *pid_cfg, mtime_t sample_period)
|
||||
{
|
||||
pid_cfg->sample_period = sample_period;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear a pid control structure
|
||||
*/
|
||||
INLINE void pid_control_reset(PidContext *pid_ctx)
|
||||
{
|
||||
pid_ctx->i_state = 0;
|
||||
pid_ctx->prev_err = 0;
|
||||
}
|
||||
|
||||
piddata_t pid_control_update(PidContext *pid_ctx, piddata_t target, piddata_t curr_pos);
|
||||
void pid_control_init(PidContext *pid_ctx, const PidCfg *pid_cfg);
|
||||
|
||||
#endif /* ALGO_PID_CONTROL_H */
|
@ -1,200 +0,0 @@
|
||||
/*!
|
||||
* \file
|
||||
* <!--
|
||||
* Copyright 2004, 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Compute, save and load ramps for stepper motors (implementation)
|
||||
*
|
||||
*
|
||||
* \author Simone Zinanni <s.zinanni@develer.com>
|
||||
* \author Bernie Innocenti <bernie@codewiz.org>
|
||||
* \author Giovanni Bajo <rasky@develer.com>
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
*
|
||||
* The formula used by the ramp is the following:
|
||||
*
|
||||
* <pre>
|
||||
* a * b
|
||||
* f(t) = -------------
|
||||
* lerp(a,b,t)
|
||||
* </pre>
|
||||
*
|
||||
* Where <code>a</code> and <code>b</code> are the maximum and minimum speed
|
||||
* respectively (minimum and maximum wavelength respectively), and <code>lerp</code>
|
||||
* is a linear interpolation with a factor:
|
||||
*
|
||||
* <pre>
|
||||
* lerp(a,b,t) = a + t * (b - a) = (a * (1 - t)) + (b * t)
|
||||
* </pre>
|
||||
*
|
||||
* <code>t</code> must be in the [0,1] interval. It is easy to see that the
|
||||
* following holds true:
|
||||
*
|
||||
* <pre>
|
||||
* f(0) = b, f(1) = a
|
||||
* </pre>
|
||||
*
|
||||
* And that the function is monotonic. So, the function effectively interpolates
|
||||
* between the maximum and minimum speed through its domain ([0,1] -> [b,a]).
|
||||
*
|
||||
* The curve drawn by this function is similar to 1 / (sqrt(n)), so it is slower
|
||||
* than a linear acceleration (which would be 1/n).
|
||||
*
|
||||
* The floating point version uses a slightly modified function which accepts
|
||||
* the parameter in the domain [0, MT] (where MT is maxTime, the length of the
|
||||
* ramp, which is a setup parameter for the ramp). This is done to reduce the
|
||||
* number of operations per step. The formula looks like this:
|
||||
*
|
||||
* <pre>
|
||||
* a * b * MT
|
||||
* g(t) = ----------------------------
|
||||
* (a * MT) + t * (b - a)
|
||||
* </pre>
|
||||
*
|
||||
* It can be shown that this <code>g(t) = f(t * MT)</code>. The denominator
|
||||
* is a linear interpolation in the range [b*MT, a*MT], as t moves in the
|
||||
* interval [0, MT]. So the interpolation interval of the function is again
|
||||
* [b, a]. The implementation caches the value of the numerator and parts
|
||||
* of the denominator, so that the formula becomes:
|
||||
*
|
||||
* <pre>
|
||||
* alpha = a * b * MT
|
||||
* beta = a * MT
|
||||
* gamma = b - a
|
||||
*
|
||||
* alpha
|
||||
* g(t) = ----------------------
|
||||
* beta + t * gamma
|
||||
* </pre>
|
||||
*
|
||||
* and <code>t</code> is exactly the parameter that ramp_evaluate() gets,
|
||||
* that is the current time (in range [0, MT]). The operations performed
|
||||
* for each step are just an addition, a multiplication and a division.
|
||||
*
|
||||
* The fixed point version of the formula instead transforms the original
|
||||
* function as follows:
|
||||
*
|
||||
* <pre>
|
||||
* a * b a
|
||||
* f(t) = ------------------------- = --------------------
|
||||
* a a
|
||||
* b * ( - * (1 - t) + t ) - * (1 - t) + t
|
||||
* b b
|
||||
* </pre>
|
||||
*
|
||||
* <code>t</code> must be computed by dividing the current time (24 bit integer)
|
||||
* by the maximum time (24 bit integer). This is done by precomputing the
|
||||
* reciprocal of the maximum time as a 0.32 fixed point number, and multiplying
|
||||
* it to the current time. Multiplication is performed 8-bits a time by
|
||||
* FIX_MULT32(), so that we end up with a 0.16 fixed point number for
|
||||
* <code>t</code> (and <code>1-t</code> is just its twos-complement negation).
|
||||
* <code>a/b</code> is in the range [0,1] (because a is always less than b,
|
||||
* being the minimum wavelength), so it is precomputed as a 0.16 fixed point.
|
||||
* The final step is then computing the denominator and executing the division
|
||||
* (32 cycles using the 1-step division instruction in the DSP).
|
||||
*
|
||||
* The assembly implementation is needed for efficiency, but a C version of it
|
||||
* can be easily written, in case it is needed in the future.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ramp.h"
|
||||
#include <cfg/debug.h>
|
||||
|
||||
#include <string.h> // memcpy()
|
||||
|
||||
void ramp_compute(struct Ramp *ramp, uint32_t clocksRamp, uint16_t clocksMinWL, uint16_t clocksMaxWL)
|
||||
{
|
||||
ASSERT(clocksMaxWL >= clocksMinWL);
|
||||
|
||||
// Save values in ramp struct
|
||||
ramp->clocksRamp = clocksRamp;
|
||||
ramp->clocksMinWL = clocksMinWL;
|
||||
ramp->clocksMaxWL = clocksMaxWL;
|
||||
|
||||
#if RAMP_USE_FLOATING_POINT
|
||||
ramp->precalc.gamma = ramp->clocksMaxWL - ramp->clocksMinWL;
|
||||
ramp->precalc.beta = (float)ramp->clocksMinWL * (float)ramp->clocksRamp;
|
||||
ramp->precalc.alpha = ramp->precalc.beta * (float)ramp->clocksMaxWL;
|
||||
|
||||
#else
|
||||
ramp->precalc.max_div_min = ((uint32_t)clocksMinWL << 16) / (uint32_t)clocksMaxWL;
|
||||
|
||||
/* Calcola 1/total_time in fixed point .32. Assumiamo che la rampa possa al
|
||||
* massimo avere 25 bit (cioé valore in tick fino a 2^25, che con il
|
||||
* prescaler=3 sono circa 7 secondi). Inoltre, togliamo qualche bit di precisione
|
||||
* da destra (secondo quanto specificato in RAMP_CLOCK_SHIFT_PRECISION).
|
||||
*/
|
||||
ASSERT(ramp->clocksRamp < (1UL << (24 + RAMP_CLOCK_SHIFT_PRECISION)));
|
||||
ramp->precalc.inv_total_time = 0xFFFFFFFFUL / (ramp->clocksRamp >> RAMP_CLOCK_SHIFT_PRECISION);
|
||||
ASSERT(ramp->precalc.inv_total_time < 0x1000000UL);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ramp_setup(struct Ramp* ramp, uint32_t length, uint32_t minFreq, uint32_t maxFreq)
|
||||
{
|
||||
uint32_t minWL, maxWL;
|
||||
|
||||
minWL = TIME2CLOCKS(FREQ2MICROS(maxFreq));
|
||||
maxWL = TIME2CLOCKS(FREQ2MICROS(minFreq));
|
||||
|
||||
ASSERT2(minWL < 65536UL, "Maximum frequency too high");
|
||||
ASSERT2(maxWL < 65536UL, "Minimum frequency too high");
|
||||
ASSERT(maxFreq > minFreq);
|
||||
|
||||
ramp_compute(
|
||||
ramp,
|
||||
TIME2CLOCKS(length),
|
||||
TIME2CLOCKS(FREQ2MICROS(maxFreq)),
|
||||
TIME2CLOCKS(FREQ2MICROS(minFreq))
|
||||
);
|
||||
}
|
||||
|
||||
void ramp_default(struct Ramp *ramp)
|
||||
{
|
||||
ramp_setup(ramp, RAMP_DEF_TIME, RAMP_DEF_MINFREQ, RAMP_DEF_MAXFREQ);
|
||||
}
|
||||
|
||||
#if RAMP_USE_FLOATING_POINT
|
||||
|
||||
float ramp_evaluate(const struct Ramp* ramp, float curClock)
|
||||
{
|
||||
return ramp->precalc.alpha / (curClock * ramp->precalc.gamma + ramp->precalc.beta);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
INLINE uint32_t fix_mult32(uint32_t m1, uint32_t m2)
|
||||
{
|
||||
uint32_t accum = 0;
|
||||
accum += m1 * ((m2 >> 0) & 0xFF);
|
||||
accum >>= 8;
|
||||
accum += m1 * ((m2 >> 8) & 0xFF);
|
||||
accum >>= 8;
|
||||
accum += m1 * ((m2 >> 16) & 0xFF);
|
||||
return accum;
|
||||
}
|
||||
|
||||
// a*b >> 16
|
||||
INLINE uint16_t fix_mult16(uint16_t a, uint32_t b)
|
||||
{
|
||||
return (b*(uint32_t)a) >> 16;
|
||||
}
|
||||
|
||||
uint16_t FAST_FUNC ramp_evaluate(const struct Ramp* ramp, uint32_t curClock)
|
||||
{
|
||||
uint16_t t = FIX_MULT32(curClock >> RAMP_CLOCK_SHIFT_PRECISION, ramp->precalc.inv_total_time);
|
||||
uint16_t denom = fix_mult16((uint16_t)~t + 1, ramp->precalc.max_div_min) + t;
|
||||
uint16_t cur_delta = ((uint32_t)ramp->clocksMinWL << 16) / denom;
|
||||
|
||||
return cur_delta;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,166 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* Copyright 2004, 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Compute, save and load ramps for stepper motors.
|
||||
*
|
||||
* The acceleration ramp is used to properly accelerate a stepper motor. The main
|
||||
* entry point is the function ramp_evaluate(), which must be called at every step
|
||||
* of the motor: it gets as input the time elapsed since the stepper started
|
||||
* accelerating, and returns the time to wait before sending the next step. A pseudo
|
||||
* usage pattern is as follows:
|
||||
*
|
||||
* <pre>
|
||||
* float time = 0;
|
||||
* while (1)
|
||||
* {
|
||||
* float delta = ramp_evaluate(&my_ramp, time);
|
||||
* sleep(delta);
|
||||
* do_motor_step();
|
||||
* time += delta;
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* A similar pattern can be used to decelerate (it is sufficient to move the total
|
||||
* time backward, such as "time -= delta").
|
||||
*
|
||||
* The ramp can be configured with ramp_setup(), providing it with the minimum and
|
||||
* maximum operating frequency of the motor, and the total acceleration time in
|
||||
* milliseconds (that is, the time that will be needed to accelerate from the
|
||||
* minimum frequency to the maximum frequency).
|
||||
*
|
||||
* Both a very precise floating point and a very fast fixed point implementation
|
||||
* of the ramp evaluation are provided. The fixed point is hand-optimized assembly
|
||||
* for DSP56000 (but a portable C version of it can be easily written, see the
|
||||
* comments in the code).
|
||||
*
|
||||
*
|
||||
* \author Simone Zinanni <s.zinanni@develer.com>
|
||||
* \author Giovanni Bajo <rasky@develer.com>
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
* $WIZ$ module_name = "ramp"
|
||||
* $WIZ$ module_configuration = "bertos/cfg/cfg_ramp.h"
|
||||
*/
|
||||
|
||||
#ifndef ALGO_RAMP_H
|
||||
#define ALGO_RAMP_H
|
||||
|
||||
#include "hw/hw_stepper.h"
|
||||
|
||||
#include "cfg/cfg_ramp.h"
|
||||
|
||||
#include <cfg/compiler.h>
|
||||
|
||||
|
||||
/**
|
||||
* Convert microseconds to timer clock ticks
|
||||
*/
|
||||
#define TIME2CLOCKS(micros) ((uint32_t)(micros) * (STEPPER_CLOCK / 1000000))
|
||||
|
||||
/**
|
||||
* Convert timer clock ticks back to microseconds
|
||||
*/
|
||||
#define CLOCKS2TIME(clocks) ((uint32_t)(clocks) / (STEPPER_CLOCK / 1000000))
|
||||
|
||||
/**
|
||||
* Convert microseconds to Hz
|
||||
*/
|
||||
#define MICROS2FREQ(micros) (1000000UL / ((uint32_t)(micros)))
|
||||
|
||||
/**
|
||||
* Convert frequency (in Hz) to time (in microseconds)
|
||||
*/
|
||||
#define FREQ2MICROS(hz) (1000000UL / ((uint32_t)(hz)))
|
||||
|
||||
/**
|
||||
* Multiply \p a and \p b two integer at 32 bit and extract the high 16 bit word.
|
||||
*/
|
||||
#define FIX_MULT32(a,b) (((uint64_t)(a)*(uint32_t)(b)) >> 16)
|
||||
|
||||
/**
|
||||
* Structure holding pre-calculated data for speeding up real-time evaluation
|
||||
* of the ramp. This structure is totally different between the fixed and the
|
||||
* floating point version of the code.
|
||||
*
|
||||
* Consult the file-level documentation of ramp.c for more information about
|
||||
* the values of this structure.
|
||||
*/
|
||||
struct RampPrecalc
|
||||
{
|
||||
#if RAMP_USE_FLOATING_POINT
|
||||
float beta;
|
||||
float alpha;
|
||||
float gamma;
|
||||
#else
|
||||
uint16_t max_div_min;
|
||||
uint32_t inv_total_time;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Ramp structure
|
||||
*/
|
||||
struct Ramp
|
||||
{
|
||||
uint32_t clocksRamp;
|
||||
uint16_t clocksMinWL;
|
||||
uint16_t clocksMaxWL;
|
||||
|
||||
struct RampPrecalc precalc; ///< pre-calculated values for speed
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
void ramp_compute(
|
||||
struct Ramp * ramp,
|
||||
uint32_t clocksInRamp,
|
||||
uint16_t clocksInMinWavelength,
|
||||
uint16_t clocksInMaxWavelength);
|
||||
|
||||
|
||||
/** Setup an acceleration ramp for a stepper motor
|
||||
*
|
||||
* \param ramp Ramp to fill
|
||||
* \param length Length of the ramp (milliseconds)
|
||||
* \param minFreq Minimum operating frequency of the motor (hertz)
|
||||
* \param maxFreq Maximum operating frequency of the motor (hertz)
|
||||
*
|
||||
*/
|
||||
void ramp_setup(struct Ramp* ramp, uint32_t length, uint32_t minFreq, uint32_t maxFreq);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize a new ramp with default values
|
||||
*/
|
||||
void ramp_default(struct Ramp *ramp);
|
||||
|
||||
|
||||
/**
|
||||
* Evaluate the ramp at the given point. Given a \a ramp, and the current \a clock since
|
||||
* the start of the acceleration, compute the next step, that is the interval at which
|
||||
* send the signal to the motor.
|
||||
*
|
||||
* \note The fixed point version does not work when curClock is zero. Anyway,
|
||||
* the first step is always clocksMaxWL, as stored within the ramp structure.
|
||||
*/
|
||||
#if RAMP_USE_FLOATING_POINT
|
||||
float ramp_evaluate(const struct Ramp* ramp, float curClock);
|
||||
#else
|
||||
uint16_t ramp_evaluate(const struct Ramp* ramp, uint32_t curClock);
|
||||
#endif
|
||||
|
||||
|
||||
/** Self test */
|
||||
int ramp_testSetup(void);
|
||||
int ramp_testRun(void);
|
||||
int ramp_testTearDown(void);
|
||||
|
||||
#endif /* ALGO_RAMP_H */
|
||||
|
@ -1,186 +0,0 @@
|
||||
/*!
|
||||
* \file
|
||||
* <!--
|
||||
* Copyright 2004, 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Test for compute, save and load ramps for stepper motors (implementation)
|
||||
*
|
||||
*
|
||||
* \author Simone Zinanni <s.zinanni@develer.com>
|
||||
* \author Bernie Innocenti <bernie@codewiz.org>
|
||||
* \author Giovanni Bajo <rasky@develer.com>
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
*
|
||||
* The formula used by the ramp is the following:
|
||||
*
|
||||
* <pre>
|
||||
* a * b
|
||||
* f(t) = -------------
|
||||
* lerp(a,b,t)
|
||||
* </pre>
|
||||
*
|
||||
* Where <code>a</code> and <code>b</code> are the maximum and minimum speed
|
||||
* respectively (minimum and maximum wavelength respectively), and <code>lerp</code>
|
||||
* is a linear interpolation with a factor:
|
||||
*
|
||||
* <pre>
|
||||
* lerp(a,b,t) = a + t * (b - a) = (a * (1 - t)) + (b * t)
|
||||
* </pre>
|
||||
*
|
||||
* <code>t</code> must be in the [0,1] interval. It is easy to see that the
|
||||
* following holds true:
|
||||
*
|
||||
* <pre>
|
||||
* f(0) = b, f(1) = a
|
||||
* </pre>
|
||||
*
|
||||
* And that the function is monotonic. So, the function effectively interpolates
|
||||
* between the maximum and minimum speed through its domain ([0,1] -> [b,a]).
|
||||
*
|
||||
* The curve drawn by this function is similar to 1 / (sqrt(n)), so it is slower
|
||||
* than a linear acceleration (which would be 1/n).
|
||||
*
|
||||
* The floating point version uses a slightly modified function which accepts
|
||||
* the parameter in the domain [0, MT] (where MT is maxTime, the length of the
|
||||
* ramp, which is a setup parameter for the ramp). This is done to reduce the
|
||||
* number of operations per step. The formula looks like this:
|
||||
*
|
||||
* <pre>
|
||||
* a * b * MT
|
||||
* g(t) = ----------------------------
|
||||
* (a * MT) + t * (b - a)
|
||||
* </pre>
|
||||
*
|
||||
* It can be shown that this <code>g(t) = f(t * MT)</code>. The denominator
|
||||
* is a linear interpolation in the range [b*MT, a*MT], as t moves in the
|
||||
* interval [0, MT]. So the interpolation interval of the function is again
|
||||
* [b, a]. The implementation caches the value of the numerator and parts
|
||||
* of the denominator, so that the formula becomes:
|
||||
*
|
||||
* <pre>
|
||||
* alpha = a * b * MT
|
||||
* beta = a * MT
|
||||
* gamma = b - a
|
||||
*
|
||||
* alpha
|
||||
* g(t) = ----------------------
|
||||
* beta + t * gamma
|
||||
* </pre>
|
||||
*
|
||||
* and <code>t</code> is exactly the parameter that ramp_evaluate() gets,
|
||||
* that is the current time (in range [0, MT]). The operations performed
|
||||
* for each step are just an addition, a multiplication and a division.
|
||||
*
|
||||
* The fixed point version of the formula instead transforms the original
|
||||
* function as follows:
|
||||
*
|
||||
* <pre>
|
||||
* a * b a
|
||||
* f(t) = ------------------------- = --------------------
|
||||
* a a
|
||||
* b * ( - * (1 - t) + t ) - * (1 - t) + t
|
||||
* b b
|
||||
* </pre>
|
||||
*
|
||||
* <code>t</code> must be computed by dividing the current time (24 bit integer)
|
||||
* by the maximum time (24 bit integer). This is done by precomputing the
|
||||
* reciprocal of the maximum time as a 0.32 fixed point number, and multiplying
|
||||
* it to the current time. Multiplication is performed 8-bits a time by
|
||||
* FIX_MULT32(), so that we end up with a 0.16 fixed point number for
|
||||
* <code>t</code> (and <code>1-t</code> is just its twos-complement negation).
|
||||
* <code>a/b</code> is in the range [0,1] (because a is always less than b,
|
||||
* being the minimum wavelength), so it is precomputed as a 0.16 fixed point.
|
||||
* The final step is then computing the denominator and executing the division
|
||||
* (32 cycles using the 1-step division instruction in the DSP).
|
||||
*
|
||||
* The assembly implementation is needed for efficiency, but a C version of it
|
||||
* can be easily written, in case it is needed in the future.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ramp.h"
|
||||
#include <cfg/debug.h>
|
||||
#include <cfg/test.h>
|
||||
|
||||
|
||||
static bool ramp_test_single(uint32_t minFreq, uint32_t maxFreq, uint32_t length)
|
||||
{
|
||||
struct Ramp r;
|
||||
uint16_t cur, old;
|
||||
uint32_t clock;
|
||||
uint32_t oldclock;
|
||||
|
||||
ramp_setup(&r, length, minFreq, maxFreq);
|
||||
|
||||
cur = old = r.clocksMaxWL;
|
||||
clock = 0;
|
||||
oldclock = 0;
|
||||
|
||||
kprintf("testing ramp: (length=%lu, min=%lu, max=%lu)\n", (unsigned long)length, (unsigned long)minFreq, (unsigned long)maxFreq);
|
||||
kprintf(" [length=%lu, max=%04x, min=%04x]\n", (unsigned long)r.clocksRamp, r.clocksMaxWL, r.clocksMinWL);
|
||||
|
||||
int i = 0;
|
||||
int nonbyte = 0;
|
||||
|
||||
while (clock + cur < r.clocksRamp)
|
||||
{
|
||||
oldclock = clock;
|
||||
old = cur;
|
||||
|
||||
clock += cur;
|
||||
cur = ramp_evaluate(&r, clock);
|
||||
|
||||
if (old < cur)
|
||||
{
|
||||
uint16_t t1 = FIX_MULT32(oldclock >> RAMP_CLOCK_SHIFT_PRECISION, r.precalc.inv_total_time);
|
||||
uint16_t t2 = FIX_MULT32(clock >> RAMP_CLOCK_SHIFT_PRECISION, r.precalc.inv_total_time);
|
||||
uint16_t denom1 = FIX_MULT32((uint16_t)((~t1) + 1), r.precalc.max_div_min) + t1;
|
||||
uint16_t denom2 = FIX_MULT32((uint16_t)((~t2) + 1), r.precalc.max_div_min) + t2;
|
||||
|
||||
kprintf(" Failed: %04x @ %lu --> %04x @ %lu\n", old, (unsigned long)oldclock, cur, (unsigned long)clock);
|
||||
kprintf(" T: %04x -> %04x\n", t1, t2);
|
||||
kprintf(" DENOM: %04x -> %04x\n", denom1, denom2);
|
||||
|
||||
cur = ramp_evaluate(&r, clock);
|
||||
return false;
|
||||
}
|
||||
i++;
|
||||
if ((old-cur) >= 256)
|
||||
nonbyte++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
kprintf("Test finished: %04x @ %lu [min=%04x, totlen=%lu, numsteps:%d, nonbyte:%d]\n", cur, (unsigned long)clock, r.clocksMinWL, (unsigned long)r.clocksRamp, i, nonbyte);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int ramp_testSetup(void)
|
||||
{
|
||||
kdbg_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ramp_testTearDown(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ramp_testRun(void)
|
||||
{
|
||||
#define TEST_RAMP(min, max, len) do { \
|
||||
if (!ramp_test_single(min, max, len)) \
|
||||
return -1; \
|
||||
} while(0)
|
||||
|
||||
TEST_RAMP(200, 5000, 3000000);
|
||||
TEST_RAMP(1000, 2000, 1000000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST_MAIN(ramp);
|
@ -1,52 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2006 Develer S.r.l. (http://www.develer.com/)
|
||||
* Copyright 1999 Bernie Innocenti <bernie@codewiz.org>
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Very simple rand() algorithm.
|
||||
*
|
||||
* \author Bernie Innocenti <bernie@codewiz.org>
|
||||
*/
|
||||
|
||||
#include "rand.h"
|
||||
|
||||
/**
|
||||
* This would really belong to libc
|
||||
*/
|
||||
int rand(void)
|
||||
{
|
||||
static unsigned long seed;
|
||||
|
||||
/* Randomize seed */
|
||||
seed = (seed ^ 0x4BAD5A39UL) + 6513973UL;
|
||||
|
||||
return (int)(seed>>16);
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2006 Develer S.r.l. (http://www.develer.com/)
|
||||
* Copyright 1999 Bernie Innocenti <bernie@codewiz.org>
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Very simple rand() algorithm.
|
||||
*
|
||||
* \author Bernie Innocenti <bernie@codewiz.org>
|
||||
*/
|
||||
|
||||
#ifndef RAND_H
|
||||
#define RAND_H
|
||||
|
||||
int rand(void);
|
||||
|
||||
#endif
|
@ -1,257 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2007 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief API function for to manage entropy pool.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#include "randpool.h"
|
||||
#include "md2.h"
|
||||
|
||||
#include <cfg/compiler.h>
|
||||
#include <cfg/debug.h> //ASSERT()
|
||||
#include <cfg/macros.h> //MIN(), ROUND_UP();
|
||||
|
||||
#include <stdio.h> //sprintf();
|
||||
#include <string.h> //memset(), memcpy();
|
||||
|
||||
#if CONFIG_RANDPOOL_TIMER
|
||||
#include <drv/timer.h> //timer_clock();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Insert bytes in entropy pool, making a XOR of bytes present
|
||||
* in entropy pool.
|
||||
*/
|
||||
static void randpool_push(EntropyPool *pool, void *_byte, size_t n_byte)
|
||||
{
|
||||
size_t i = pool->pos_add; // Current number of byte insert in entropy pool.
|
||||
uint8_t *byte;
|
||||
|
||||
byte = (uint8_t *)_byte;
|
||||
|
||||
/*
|
||||
* Insert a bytes in entropy pool.
|
||||
*/
|
||||
for(size_t j = 0; j < n_byte; j++)
|
||||
{
|
||||
pool->pool_entropy[i] = pool->pool_entropy[i] ^ byte[j];
|
||||
i++;
|
||||
i = i % CONFIG_SIZE_ENTROPY_POOL;
|
||||
}
|
||||
|
||||
pool->pos_add = i; // Update a insert bytes.
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function stir entropy pool with MD2 function hash.
|
||||
*
|
||||
*/
|
||||
static void randpool_stir(EntropyPool *pool)
|
||||
{
|
||||
size_t entropy = pool->entropy; //Save current calue of entropy.
|
||||
Md2Context context;
|
||||
uint8_t tmp_buf[((sizeof(size_t) * 2) + sizeof(int)) * 2 + 1]; //Temporary buffer.
|
||||
|
||||
md2_init(&context); //Init MD2 algorithm.
|
||||
|
||||
randpool_add(pool, NULL, 0);
|
||||
|
||||
for (int i = 0; i < (CONFIG_SIZE_ENTROPY_POOL / MD2_DIGEST_LEN); i++)
|
||||
{
|
||||
sprintf((char *)tmp_buf, "%0x%0x%0x", pool->counter, i, pool->pos_add);
|
||||
|
||||
/*
|
||||
* Hash with MD2 algorithm the entropy pool.
|
||||
*/
|
||||
md2_update(&context, pool->pool_entropy, CONFIG_SIZE_ENTROPY_POOL);
|
||||
|
||||
md2_update(&context, tmp_buf, sizeof(tmp_buf) - 1);
|
||||
|
||||
/*Insert a message digest in entropy pool.*/
|
||||
randpool_push(pool, md2_end(&context), MD2_DIGEST_LEN);
|
||||
|
||||
pool->counter = pool->counter + 1;
|
||||
|
||||
}
|
||||
|
||||
/*Insert in pool the difference between a two call of this function (see above).*/
|
||||
randpool_add(pool, NULL, 0);
|
||||
|
||||
pool->entropy = entropy; //Restore old value of entropy. We haven't add entropy.
|
||||
}
|
||||
|
||||
/**
|
||||
* Add \param entropy bits from \param data buffer to the entropy \param pool
|
||||
*/
|
||||
void randpool_add(EntropyPool *pool, void *data, size_t entropy)
|
||||
{
|
||||
uint8_t sep[] = "\xaa\xaa\xaa\xaa"; // ??
|
||||
size_t data_len = ROUND_UP(entropy, 8) / 8; //Number of entropy byte in input.
|
||||
|
||||
randpool_push(pool, data, data_len); //Insert data to entropy pool.
|
||||
|
||||
#if CONFIG_RANDPOOL_TIMER
|
||||
|
||||
ticks_t event = timer_clock();
|
||||
ticks_t delta;
|
||||
|
||||
/*Difference of time between a two accese to entropy pool.*/
|
||||
delta = event - pool->last_counter;
|
||||
|
||||
randpool_push(pool, &event, sizeof(ticks_t));
|
||||
randpool_push(pool, sep, sizeof(sep) - 1); // ??
|
||||
randpool_push(pool, &delta, sizeof(delta));
|
||||
|
||||
/*
|
||||
* Count of number entropy bit add with delta.
|
||||
*/
|
||||
delta = delta & 0xff;
|
||||
while(delta)
|
||||
{
|
||||
delta >>= 1;
|
||||
entropy++;
|
||||
}
|
||||
|
||||
pool->last_counter = event;
|
||||
|
||||
#endif
|
||||
|
||||
pool->entropy += entropy; //Update a entropy of the pool.
|
||||
}
|
||||
|
||||
/**
|
||||
* Randpool function initialization.
|
||||
* The entropy pool can be initialize also with
|
||||
* a previous entropy pool.
|
||||
*/
|
||||
void randpool_init(EntropyPool *pool, void *_data, size_t len)
|
||||
{
|
||||
uint8_t *data;
|
||||
|
||||
data = (uint8_t *)_data;
|
||||
|
||||
memset(pool, 0, sizeof(EntropyPool));
|
||||
pool->pos_get = MD2_DIGEST_LEN;
|
||||
|
||||
#if CONFIG_RANDPOOL_TIMER
|
||||
pool->last_counter = timer_clock();
|
||||
#endif
|
||||
|
||||
if(data)
|
||||
{
|
||||
/*
|
||||
* Initialize a entropy pool with a
|
||||
* previous pool, and assume all pool as
|
||||
* entropy.
|
||||
*/
|
||||
len = MIN(len,(size_t)CONFIG_SIZE_ENTROPY_POOL);
|
||||
memcpy(pool->pool_entropy, data, len);
|
||||
pool->entropy = len;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual value of entropy.
|
||||
*/
|
||||
size_t randpool_size(EntropyPool *pool)
|
||||
{
|
||||
return pool->entropy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get \param n_byte from entropy pool. If n_byte is larger than number
|
||||
* byte of entropy in entropy pool, randpool_get continue
|
||||
* to generate pseudocasual value from previous state of
|
||||
* pool.
|
||||
* \param n_byte number fo bytes to read.
|
||||
* \param pool is the pool entropy context.
|
||||
* \param _data is the pointer to write the random data to.
|
||||
*/
|
||||
void randpool_get(EntropyPool *pool, void *_data, size_t n_byte)
|
||||
{
|
||||
Md2Context context;
|
||||
size_t i = pool->pos_get;
|
||||
size_t n = n_byte;
|
||||
size_t pos_write = 0; //Number of block has been written in data.
|
||||
size_t len = MIN((size_t)MD2_DIGEST_LEN, n_byte);
|
||||
uint8_t *data;
|
||||
|
||||
data = (uint8_t *)_data;
|
||||
|
||||
/* Test if i + CONFIG_MD2_BLOCK_LEN is inside of entropy pool.*/
|
||||
ASSERT((MD2_DIGEST_LEN + i) <= CONFIG_SIZE_ENTROPY_POOL);
|
||||
|
||||
md2_init(&context);
|
||||
|
||||
while(n > 0)
|
||||
{
|
||||
|
||||
/*Hash previous state of pool*/
|
||||
md2_update(&context, &pool->pool_entropy[i], MD2_DIGEST_LEN);
|
||||
|
||||
memcpy(&data[pos_write], md2_end(&context), len);
|
||||
|
||||
pos_write += len; //Update number of block has been written in data.
|
||||
n -= len; //Number of byte copied in data.
|
||||
|
||||
len = MIN(n,(size_t)MD2_DIGEST_LEN);
|
||||
|
||||
i = (i + MD2_DIGEST_LEN) % CONFIG_SIZE_ENTROPY_POOL;
|
||||
|
||||
/* If we haven't more entropy pool to hash, we stir it.*/
|
||||
if(i < MD2_DIGEST_LEN)
|
||||
{
|
||||
randpool_stir(pool);
|
||||
i = pool->pos_get;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pool->pos_get = i; //Current number of byte we get from pool.
|
||||
pool->entropy -= n_byte; //Update a entropy.
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pointer to entropy pool.
|
||||
*/
|
||||
uint8_t *randpool_pool(EntropyPool *pool)
|
||||
{
|
||||
return pool->pool_entropy;
|
||||
}
|
||||
|
@ -1,75 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2007 Develer S.r.l. (http://www.develer.com/);
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Collection of functions to manage entropy pool.
|
||||
*
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
* $WIZ$ module_name = "randpool"
|
||||
* $WIZ$ module_depends = "timer", "sprintf"
|
||||
* $WIZ$ module_configuration = "bertos/cfg/cfg_randpool.h"
|
||||
*/
|
||||
|
||||
#ifndef ALGO_RANDPOOL_H
|
||||
#define ALGO_RANDPOOL_H
|
||||
|
||||
#include "cfg/cfg_randpool.h"
|
||||
#include <cfg/compiler.h>
|
||||
|
||||
|
||||
/**
|
||||
* Sturct data of entropy pool.
|
||||
*/
|
||||
typedef struct EntropyPool
|
||||
{
|
||||
size_t entropy; ///< Actual value of entropy (byte).
|
||||
size_t pos_add; ///< Number of byte added in entropy pool.
|
||||
size_t pos_get; ///< Number of byte got in entropy pool.
|
||||
size_t counter; ///< Counter.
|
||||
|
||||
#if CONFIG_RANDPOOL_TIMER
|
||||
size_t last_counter; ///< Last timer value.
|
||||
#endif
|
||||
|
||||
uint8_t pool_entropy[CONFIG_SIZE_ENTROPY_POOL]; ///< Entropy pool.
|
||||
|
||||
} EntropyPool;
|
||||
|
||||
|
||||
void randpool_add(EntropyPool *pool, void *data, size_t entropy);
|
||||
void randpool_init(EntropyPool *pool, void *_data, size_t len);
|
||||
size_t randpool_size(EntropyPool *pool);
|
||||
void randpool_get(EntropyPool *pool, void *data, size_t n_byte);
|
||||
uint8_t *randpool_pool(EntropyPool *pool);
|
||||
|
||||
#endif /* ALGO_RANDPOOL_H */
|
@ -1,87 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
|
||||
* Copyright 1999 Bernie Innocenti <bernie@codewiz.org>
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief REVERSE macro test.
|
||||
*
|
||||
* \author Francesco Sacchi <batt@develer.com>
|
||||
*/
|
||||
|
||||
#include <cfg/macros.h>
|
||||
#include <cfg/debug.h>
|
||||
#include <cfg/test.h>
|
||||
|
||||
|
||||
/* Silent compiler warning */
|
||||
int reverse_testSetup(void);
|
||||
int reverse_testRun(void);
|
||||
int reverse_testTearDown(void);
|
||||
|
||||
|
||||
int reverse_testSetup(void)
|
||||
{
|
||||
kdbg_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int reverse_testTearDown(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Naive reverse implementation.
|
||||
*/
|
||||
static uint8_t reverse(uint8_t b)
|
||||
{
|
||||
uint8_t r = 0;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
r <<= 1;
|
||||
r |= (b & BV(i)) ? 1 : 0;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int reverse_testRun(void)
|
||||
{
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
kprintf("i [%02X], REVERSE(i) [%02X], reverse(i) [%02X]\n", i, REVERSE_UINT8(i), reverse(i));
|
||||
ASSERT(reverse(i) == REVERSE_UINT8(i));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST_MAIN(reverse);
|
@ -1,150 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2004 Develer S.r.l. (http://www.develer.com/)
|
||||
* Copyright 1999, 2000, 2001 Bernie Innocenti <bernie@codewiz.org>
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief General-purpose run-length {en,de}coding algorithm (implementation)
|
||||
*
|
||||
* Original source code from http://www.compuphase.com/compress.htm
|
||||
*
|
||||
* \author Bernie Innocenti <bernie@codewiz.org>
|
||||
*/
|
||||
|
||||
#include "rle.h"
|
||||
|
||||
|
||||
/**
|
||||
* Run-length encode \a len bytes from the \a input buffer
|
||||
* to the \a output buffer.
|
||||
*/
|
||||
int rle(unsigned char *output, const unsigned char *input, int len)
|
||||
{
|
||||
int count, index, i;
|
||||
unsigned char first;
|
||||
unsigned char *out;
|
||||
|
||||
|
||||
out = output;
|
||||
count = 0;
|
||||
while (count < len)
|
||||
{
|
||||
index = count;
|
||||
first = input[index++];
|
||||
|
||||
/* Scan for bytes identical to the first one */
|
||||
while ((index < len) && (index - count < 127) && (input[index] == first))
|
||||
index++;
|
||||
|
||||
if (index - count == 1)
|
||||
{
|
||||
/* Failed to "replicate" the current byte. See how many to copy.
|
||||
*/
|
||||
while ((index < len) && (index - count < 127))
|
||||
{
|
||||
/* Avoid a replicate run of only 2-bytes after a literal run.
|
||||
* There is no gain in this, and there is a risc of loss if the
|
||||
* run after the two identical bytes is another literal run.
|
||||
* So search for 3 identical bytes.
|
||||
*/
|
||||
if ((input[index] == input[index - 1]) &&
|
||||
((index > 1) && (input[index] == input[index - 2])))
|
||||
{
|
||||
/* Reset the index so we can back up these three identical
|
||||
* bytes in the next run.
|
||||
*/
|
||||
index -= 2;
|
||||
break;
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
/* Output a run of uncompressed bytes: write length and values */
|
||||
*out++ = (unsigned char)(count - index);
|
||||
for (i = count; i < index; i++)
|
||||
*out++ = input[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Output a compressed run: write length and value */
|
||||
*out++ = (unsigned char)(index - count);
|
||||
*out++ = first;
|
||||
}
|
||||
|
||||
count = index;
|
||||
}
|
||||
|
||||
/* Output EOF marker */
|
||||
*out++ = 0;
|
||||
|
||||
return (out - output);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run-length decode from the \a input buffer to the \a output
|
||||
* buffer.
|
||||
*
|
||||
* \note The output buffer must be large enough to accomodate
|
||||
* all decoded output.
|
||||
*/
|
||||
int unrle(unsigned char *output, const unsigned char *input)
|
||||
{
|
||||
signed char count;
|
||||
unsigned char *out;
|
||||
unsigned char value;
|
||||
|
||||
|
||||
out = output;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
count = (signed char)*input++;
|
||||
if (count > 0)
|
||||
{
|
||||
/* replicate run */
|
||||
value = *input++;
|
||||
while (count--)
|
||||
*out++ = value;
|
||||
}
|
||||
else if (count < 0)
|
||||
{
|
||||
/* literal run */
|
||||
while (count++)
|
||||
*out++ = *input++;
|
||||
}
|
||||
else
|
||||
/* EOF */
|
||||
break;
|
||||
}
|
||||
|
||||
return (out - output);
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2004 Develer S.r.l. (http://www.develer.com/)
|
||||
* Copyright 1999, 2000, 2001 Bernie Innocenti <bernie@codewiz.org>
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief General-purpose run-length {en,de}coding algorithm.
|
||||
*
|
||||
* \author Bernie Innocenti <bernie@codewiz.org>
|
||||
*
|
||||
* $WIZ$ module_name = "rle"
|
||||
*/
|
||||
#ifndef RLE_H
|
||||
#define RLE_H
|
||||
|
||||
int rle(unsigned char *output, const unsigned char *input, int length);
|
||||
int unrle(unsigned char *output, const unsigned char *input);
|
||||
|
||||
#endif /* RLE_H */
|
@ -1,83 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2007 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Rotating Hash algorithm.
|
||||
*
|
||||
* This is a simple yet powerfull checksum algorithm.
|
||||
* Instead of just xor-ing the data, rotating hash
|
||||
* circular shift the checksum 4 place left before xoring.
|
||||
* This is a bit more stronger than simply sum the data.
|
||||
*
|
||||
*
|
||||
* \author Francesco Sacchi <batt@develer.com>
|
||||
*
|
||||
* $WIZ$ module_name = "rotating_hash"
|
||||
*/
|
||||
|
||||
|
||||
#ifndef ALGO_ROTATING_H
|
||||
#define ALGO_ROTATING_H
|
||||
|
||||
#include <cfg/compiler.h>
|
||||
|
||||
typedef uint16_t rotating_t;
|
||||
|
||||
|
||||
/**
|
||||
* Init rotating checksum.
|
||||
*/
|
||||
INLINE void rotating_init(rotating_t *rot)
|
||||
{
|
||||
*rot = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update checksum pointed by \c rot with \c c data.
|
||||
*/
|
||||
INLINE void rotating_update1(uint8_t c, rotating_t *rot)
|
||||
{
|
||||
*rot = (*rot << 4) ^ (*rot >> 12) ^ c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update checksum pointed by \c rot with data supplied in \c buf.
|
||||
*/
|
||||
INLINE void rotating_update(const void *_buf, size_t len, rotating_t *rot)
|
||||
{
|
||||
const uint8_t *buf = (const uint8_t *)_buf;
|
||||
|
||||
while (len--)
|
||||
rotating_update1(*buf++, rot);
|
||||
}
|
||||
|
||||
|
||||
#endif // ALGO_ROTATING_H
|
@ -1,131 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2006 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief TEA Tiny Encription Algorith functions (implementation).
|
||||
*
|
||||
* \author Francesco Sacchi <batt@develer.com>
|
||||
*
|
||||
* The Tiny Encryption Algorithm (TEA) by David Wheeler and Roger Needham
|
||||
* of the Cambridge Computer Laboratory
|
||||
*
|
||||
* Placed in the Public Domain by David Wheeler and Roger Needham.
|
||||
*
|
||||
* **** ANSI C VERSION ****
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* TEA is a Feistel cipher with XOR and and addition as the non-linear
|
||||
* mixing functions.
|
||||
*
|
||||
* Takes 64 bits of data in v[0] and v[1]. Returns 64 bits of data in w[0]
|
||||
* and w[1]. Takes 128 bits of key in k[0] - k[3].
|
||||
*
|
||||
* TEA can be operated in any of the modes of DES. Cipher Block Chaining is,
|
||||
* for example, simple to implement.
|
||||
*
|
||||
* n is the number of iterations. 32 is ample, 16 is sufficient, as few
|
||||
* as eight may be OK. The algorithm achieves good dispersion after six
|
||||
* iterations. The iteration count can be made variable if required.
|
||||
*
|
||||
* Note this is optimised for 32-bit CPUs with fast shift capabilities. It
|
||||
* can very easily be ported to assembly language on most CPUs.
|
||||
*
|
||||
* delta is chosen to be the real part of (the golden ratio Sqrt(5/4) -
|
||||
* 1/2 ~ 0.618034 multiplied by 2^32).
|
||||
*/
|
||||
|
||||
#include "tea.h"
|
||||
#include <cpu/byteorder.h>
|
||||
|
||||
static uint32_t tea_func(uint32_t *in, uint32_t *sum, uint32_t *k)
|
||||
{
|
||||
return ((*in << 4) + cpu_to_le32(k[0])) ^ (*in + *sum) ^ ((*in >> 5) + cpu_to_le32(k[1]));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief TEA encryption function.
|
||||
* This function encrypts <EM>v</EM> with <EM>k</EM> and returns the
|
||||
* encrypted data in <EM>v</EM>.
|
||||
* \param _v Array of two long values containing the data block.
|
||||
* \param _k Array of four long values containing the key.
|
||||
*/
|
||||
void tea_enc(void *_v, void *_k)
|
||||
{
|
||||
uint32_t y, z;
|
||||
uint32_t sum = 0;
|
||||
uint8_t n = ROUNDS;
|
||||
uint32_t *v = (uint32_t *)_v;
|
||||
uint32_t *k = (uint32_t *)_k;
|
||||
|
||||
y=cpu_to_le32(v[0]);
|
||||
z=cpu_to_le32(v[1]);
|
||||
|
||||
while(n-- > 0)
|
||||
{
|
||||
sum += DELTA;
|
||||
y += tea_func(&z, &sum, &(k[0]));
|
||||
z += tea_func(&y, &sum, &(k[2]));
|
||||
}
|
||||
|
||||
v[0] = le32_to_cpu(y);
|
||||
v[1] = le32_to_cpu(z);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief TEA decryption function.
|
||||
* This function decrypts <EM>v</EM> with <EM>k</EM> and returns the
|
||||
* decrypted data in <EM>v</EM>.
|
||||
* \param _v Array of two long values containing the data block.
|
||||
* \param _k Array of four long values containing the key.
|
||||
*/
|
||||
void tea_dec(void *_v, void *_k)
|
||||
{
|
||||
uint32_t y, z;
|
||||
uint32_t sum = DELTA * ROUNDS;
|
||||
uint8_t n = ROUNDS;
|
||||
uint32_t *v = (uint32_t *)_v;
|
||||
uint32_t *k = (uint32_t *)_k;
|
||||
|
||||
y = cpu_to_le32(v[0]);
|
||||
z = cpu_to_le32(v[1]);
|
||||
|
||||
while(n-- > 0)
|
||||
{
|
||||
z -= tea_func(&y, &sum, &(k[2]));
|
||||
y -= tea_func(&z, &sum, &(k[0]));
|
||||
sum -= DELTA;
|
||||
}
|
||||
|
||||
v[0] = le32_to_cpu(y);
|
||||
v[1] = le32_to_cpu(z);
|
||||
}
|
||||
|
@ -1,58 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2006 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief TEA Tiny Encription Algorith functions.
|
||||
*
|
||||
* Documentation for TEA is available at
|
||||
* http://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm
|
||||
*
|
||||
* \author Francesco Sacchi <batt@develer.com>
|
||||
*
|
||||
* $WIZ$ module_name = "tea"
|
||||
*/
|
||||
|
||||
#ifndef ALGO_TEA_H
|
||||
#define ALGO_TEA_H
|
||||
|
||||
#include <cfg/compiler.h>
|
||||
|
||||
#define TEA_KEY_LEN 16 //!< TEA key size.
|
||||
#define TEA_BLOCK_LEN 8 //!< TEA block length.
|
||||
|
||||
#define DELTA 0x9E3779B9 //!< Magic value. (Golden number * 2^31)
|
||||
#define ROUNDS 32 //!< Number of rounds.
|
||||
|
||||
void tea_enc(void *_v, void *_k);
|
||||
void tea_dec(void *_v, void *_k);
|
||||
|
||||
#endif /* ALGO_TEA_H */
|
||||
|
@ -1,136 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Context switch benchmark
|
||||
*
|
||||
* \author Andrea Righi <arighi@develer.com>
|
||||
* \author Daniele Basiele <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#include "context_switch.h"
|
||||
|
||||
#include "hw/hw_led.h"
|
||||
|
||||
#include "cfg/cfg_context_switch.h"
|
||||
#include <cfg/debug.h>
|
||||
|
||||
#include <cpu/irq.h>
|
||||
#include <cpu/power.h>
|
||||
|
||||
#include <drv/timer.h>
|
||||
#if CONFIG_USE_HP_TIMER
|
||||
#include <drv/ser.h>
|
||||
static Serial out;
|
||||
#endif
|
||||
|
||||
#include <kern/proc.h>
|
||||
|
||||
#define PROC_STACK_SIZE KERN_MINSTACKSIZE
|
||||
|
||||
static PROC_DEFINE_STACK(hp_stack, PROC_STACK_SIZE);
|
||||
static PROC_DEFINE_STACK(lp_stack, PROC_STACK_SIZE);
|
||||
|
||||
static Process *hp_proc, *lp_proc, *main_proc;
|
||||
#if CONFIG_USE_HP_TIMER
|
||||
static hptime_t start, end;
|
||||
#endif
|
||||
|
||||
static void NORETURN hp_process(void)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
sig_wait(SIG_USER0);
|
||||
#if CONFIG_USE_LED
|
||||
LED_ON();
|
||||
#endif
|
||||
#if CONFIG_USE_HP_TIMER
|
||||
end = timer_hw_hpread();
|
||||
#endif
|
||||
sig_send(main_proc, SIG_USER0);
|
||||
}
|
||||
}
|
||||
|
||||
static void NORETURN lp_process(void)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
sig_wait(SIG_USER0);
|
||||
#if CONFIG_USE_LED
|
||||
LED_ON();
|
||||
LED_OFF();
|
||||
#endif
|
||||
#if CONFIG_USE_HP_TIMER
|
||||
start = timer_hw_hpread();
|
||||
#endif
|
||||
sig_send(hp_proc, SIG_USER0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NORETURN context_switch(void)
|
||||
{
|
||||
IRQ_ENABLE;
|
||||
timer_init();
|
||||
proc_init();
|
||||
|
||||
#if CONFIG_USE_HP_TIMER
|
||||
ser_init(&out, CONFIG_CTX_DEBUG_PORT);
|
||||
ser_setbaudrate(&out, CONFIG_CTX_DEBUG_BAUDRATE);
|
||||
#endif
|
||||
|
||||
#if CONFIG_USE_LED
|
||||
LED_INIT();
|
||||
#endif
|
||||
|
||||
proc_forbid();
|
||||
hp_proc = proc_new(hp_process, NULL, PROC_STACK_SIZE, hp_stack);
|
||||
lp_proc = proc_new(lp_process, NULL, PROC_STACK_SIZE, lp_stack);
|
||||
main_proc = proc_current();
|
||||
proc_setPri(hp_proc, 2);
|
||||
proc_setPri(lp_proc, 1);
|
||||
proc_permit();
|
||||
|
||||
while (1)
|
||||
{
|
||||
timer_delay(100);
|
||||
|
||||
sig_send(lp_proc, SIG_USER0);
|
||||
sig_wait(SIG_USER0);
|
||||
|
||||
#if CONFIG_USE_HP_TIMER
|
||||
kfile_printf(&out.fd,
|
||||
"Switch: %lu.%lu usec\n\r",
|
||||
hptime_to_us((end - start)),
|
||||
hptime_to_us((end - start) * 1000) % 1000);
|
||||
#endif
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Context switch benchmark
|
||||
*
|
||||
* \author Andrea Righi <arighi@develer.com>
|
||||
* \author Daniele Basiele <asterix@develer.com>
|
||||
*
|
||||
* $WIZ$ module_name = "context_switch"
|
||||
* $WIZ$ module_depends = "kfile", "kern", "signal", "timer"
|
||||
* $WIZ$ module_configuration = "bertos/cfg/cfg_context_switch.h"
|
||||
* $WIZ$ module_hw = "bertos/hw/hw_led.h"
|
||||
*/
|
||||
|
||||
#ifndef BENCHMARK_CONTEXT_SWITCH_H
|
||||
#define BENCHMARK_CONTEXT_SWITCH_H
|
||||
|
||||
void context_switch(void);
|
||||
|
||||
#endif /* BENCHMARK_CONTEXT_SWITCH_H */
|
@ -1,96 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \author Luca Ottaviano <lottaviano@develer.com>
|
||||
* \author Andrea Righi <arighi@develer.com>
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
* \brief Kernel footprint benchmark.
|
||||
*/
|
||||
|
||||
#include "kernel_footprint.h"
|
||||
|
||||
#include <cpu/irq.h>
|
||||
|
||||
#include <kern/proc.h>
|
||||
#include <kern/signal.h>
|
||||
#include <kern/msg.h>
|
||||
#include <kern/sem.h>
|
||||
|
||||
MsgPort in_port;
|
||||
|
||||
static void init(void)
|
||||
{
|
||||
IRQ_ENABLE;
|
||||
proc_init();
|
||||
}
|
||||
|
||||
static PROC_DEFINE_STACK(proc1_stack, KERN_MINSTACKSIZE);
|
||||
|
||||
static NORETURN void proc1_main(void)
|
||||
{
|
||||
int i;
|
||||
for(;;)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void kernel_footprint(void)
|
||||
{
|
||||
init();
|
||||
|
||||
// generate code for process
|
||||
struct Process *p =
|
||||
proc_new(proc1_main, 0, sizeof(proc1_stack), proc1_stack);
|
||||
proc_setPri(p, 5);
|
||||
proc_yield();
|
||||
|
||||
// generate code for msg
|
||||
Msg msg;
|
||||
msg_initPort(&in_port, event_createSignal(p, SIG_USER1));
|
||||
msg_put(&in_port, &msg);
|
||||
msg_peek(&in_port);
|
||||
Msg *msg_re = msg_get(&in_port);
|
||||
msg_reply(msg_re);
|
||||
|
||||
// generate code for signals
|
||||
sig_send(p, SIG_USER0);
|
||||
|
||||
// generate code for msg
|
||||
Semaphore sem;
|
||||
sem_init(&sem);
|
||||
sem_obtain(&sem);
|
||||
sem_release(&sem);
|
||||
|
||||
sig_wait(SIG_USER0);
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
* \brief Kernel footprint benchmark.
|
||||
*
|
||||
* $WIZ$ module_name = "kernel_footprint"
|
||||
* $WIZ$ module_depends = "kfile", "kern", "signal", "msg", "semaphores", "event"
|
||||
*/
|
||||
|
||||
#ifndef BENCHMARK_KERNEL_FOOTPRINT_H
|
||||
#define BENCHMARK_KERNEL_FOOTPRINT_H
|
||||
|
||||
void kernel_footprint(void);
|
||||
|
||||
#endif /* BENCHMARK_KERNEL_FOOTPRINT_H */
|
@ -1,113 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for AFSK1200 modem.
|
||||
*
|
||||
* \author Francesco Sacchi <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_AFSK_H
|
||||
#define CFG_AFSK_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define AFSK_LOG_LEVEL LOG_LVL_WARN
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define AFSK_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
|
||||
/**
|
||||
* AFSK discriminator filter type.
|
||||
*
|
||||
* $WIZ$ type = "enum"; value_list = "afsk_filter_list"
|
||||
*/
|
||||
#define CONFIG_AFSK_FILTER AFSK_CHEBYSHEV
|
||||
|
||||
|
||||
/**
|
||||
* AFSK receiver buffer length.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 2
|
||||
*/
|
||||
#define CONFIG_AFSK_RX_BUFLEN 32
|
||||
|
||||
/**
|
||||
* AFSK transimtter buffer length.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 2
|
||||
*/
|
||||
#define CONFIG_AFSK_TX_BUFLEN 32
|
||||
|
||||
/**
|
||||
* AFSK DAC sample rate for modem outout.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 2400
|
||||
*/
|
||||
#define CONFIG_AFSK_DAC_SAMPLERATE 9600
|
||||
|
||||
/**
|
||||
* AFSK RX timeout in ms, set to -1 to disable.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = -1
|
||||
*/
|
||||
#define CONFIG_AFSK_RXTIMEOUT 0
|
||||
|
||||
|
||||
/**
|
||||
* AFSK Preamble length in [ms], before starting transmissions.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_AFSK_PREAMBLE_LEN 300UL
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* AFSK Trailer length in [ms], before stopping transmissions.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_AFSK_TRAILER_LEN 50UL
|
||||
|
||||
#endif /* CFG_AFSK_H */
|
@ -1,67 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for BattFS module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_BATTFS_H
|
||||
#define CFG_BATTFS_H
|
||||
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define BATTFS_LOG_LEVEL LOG_LVL_INFO
|
||||
|
||||
/**
|
||||
* module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define BATTFS_LOG_FORMAT LOG_FMT_VERBOSE
|
||||
|
||||
/**
|
||||
* Set to 1 to enable free page shuffling.
|
||||
* This increase memories life but makes debugging
|
||||
* more difficult due to its unrepeteable state.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_BATTFS_SHUFFLE_FREE_PAGES 0
|
||||
|
||||
|
||||
#endif /* BATTFS */
|
@ -1,47 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for buzzerled module.
|
||||
*
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_BUZZERLED_H
|
||||
#define CFG_BUZZERLED_H
|
||||
|
||||
/// TODO
|
||||
#define CONFIG_NUM_BLDS 1
|
||||
|
||||
|
||||
#endif /* CFG_BUZZERLED_H */
|
||||
|
@ -1,55 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for data flash memory module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_DATAFLASH_H
|
||||
#define CFG_DATAFLASH_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define DATAFLASH_LOG_LEVEL LOG_LVL_INFO
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define DATAFLASH_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
#endif /* CFG_DATAFLASH_H */
|
@ -1,111 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for DC motor module.
|
||||
*
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_DC_MOTOR_H
|
||||
#define CFG_DC_MOTOR_H
|
||||
|
||||
/**
|
||||
* Number of the DC motors to manage.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_NUM_DC_MOTOR 4
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define DC_MOTOR_LOG_LEVEL LOG_LVL_INFO
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define DC_MOTOR_LOG_FORMAT LOG_FMT_VERBOSE
|
||||
|
||||
|
||||
/**
|
||||
* Min value of DC motor speed.
|
||||
* \note Generally this value is the min value of the ADC conversion,
|
||||
* if you use it.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_DC_MOTOR_MIN_SPEED 0
|
||||
|
||||
|
||||
/**
|
||||
* Max value of DC motor speed.
|
||||
* \note Generally this value is the max value of the ADC conversion,
|
||||
* if you use it.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ max = 65535
|
||||
*/
|
||||
#define CONFIG_DC_MOTOR_MAX_SPEED 65535
|
||||
|
||||
|
||||
/**
|
||||
* Sampling period in millisecond.
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_DC_MOTOR_SAMPLE_PERIOD 40
|
||||
|
||||
/**
|
||||
* Amount of millisecond before to read sample.
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_DC_MOTOR_SAMPLE_DELAY 2
|
||||
|
||||
/**
|
||||
* This control set which mode the driver use to lock share
|
||||
* resources when we use the preempitive kernel.
|
||||
* If we set to 1 we use the semaphore module otherwise the
|
||||
* driver disable the switch context every time we need to access
|
||||
* to shared sources.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_DC_MOTOR_USE_SEM 1
|
||||
|
||||
#endif /* CFG_DC_MOTOR_H */
|
@ -1,64 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for the Eeprom module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_EEPROM_H
|
||||
#define CFG_EEPROM_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define EEPROM_LOG_LEVEL LOG_LVL_INFO
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define EEPROM_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
/**
|
||||
* Check this to disable Eeprom deprecated API support.
|
||||
*
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_EEPROM_DISABLE_OLD_API 0
|
||||
|
||||
#endif /* CFG_EEPROM_H */
|
@ -1,73 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* -->
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
* \brief Configuration file for embedded flash module.
|
||||
*/
|
||||
|
||||
#ifndef CFG_EMB_FLASH_H
|
||||
#define CFG_EMB_FLASH_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define CONFIG_FLASH_EMB_LOG_LEVEL LOG_LVL_INFO
|
||||
|
||||
/**
|
||||
* module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define CONFIG_FLASH_EMB_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
|
||||
/**
|
||||
* Write emb flash timeout.
|
||||
* For how many milliseconds the cpu wait
|
||||
* to complete write operation.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_FLASH_WR_TIMEOUT 100
|
||||
|
||||
/**
|
||||
* Check this to disable embedded flash deprecated API support.
|
||||
*
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_FLASH_DISABLE_OLD_API 0
|
||||
|
||||
#endif /* CFG_FLASH_AT91_H */
|
@ -1,57 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \author Andrea Righi <arighi@develer.com>
|
||||
*
|
||||
* \brief Configuration file for the generic ethernet driver module
|
||||
*/
|
||||
|
||||
#ifndef CFG_ETH_H
|
||||
#define CFG_ETH_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define ETH_LOG_LEVEL LOG_LVL_WARN
|
||||
|
||||
/**
|
||||
* module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define ETH_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
#endif /* CFG_ETH_H */
|
@ -1,156 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2009 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for Fat module.
|
||||
*
|
||||
*
|
||||
* \author Luca Ottaviano <lottaviano@develer.com>
|
||||
* \author Francesco Sacchi <batt@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_FAT_H
|
||||
#define CFG_FAT_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define FAT_LOG_LEVEL LOG_LVL_ERR
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define FAT_LOG_FORMAT LOG_FMT_VERBOSE
|
||||
|
||||
|
||||
/**
|
||||
* Use word alignment to access FAT structure.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_FAT_WORD_ACCESS 0
|
||||
#define _WORD_ACCESS CONFIG_FAT_WORD_ACCESS
|
||||
|
||||
/**
|
||||
* Enable read functions only.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_FAT_FS_READONLY 0
|
||||
#define _FS_READONLY CONFIG_FAT_FS_READONLY
|
||||
|
||||
/**
|
||||
* Minimization level to remove some functions.
|
||||
* $WIZ$ type = "int"; min = 0; max = 3
|
||||
*/
|
||||
#define CONFIG_FAT_FS_MINIMIZE 0
|
||||
#define _FS_MINIMIZE CONFIG_FAT_FS_MINIMIZE
|
||||
|
||||
/**
|
||||
* If enabled, this reduces memory consumption 512 bytes each file object by using a shared buffer.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_FAT_FS_TINY 1
|
||||
#define _FS_TINY CONFIG_FAT_FS_TINY
|
||||
|
||||
/**
|
||||
* To enable string functions, set _USE_STRFUNC to 1 or 2.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ supports = "False"
|
||||
*/
|
||||
#define CONFIG_FAT_USE_STRFUNC 0
|
||||
#define _USE_STRFUNC CONFIG_FAT_USE_STRFUNC
|
||||
|
||||
/**
|
||||
* Enable f_mkfs function. Requires CONFIG_FAT_FS_READONLY = 0.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_FAT_USE_MKFS 0
|
||||
#define _USE_MKFS (CONFIG_FAT_USE_MKFS && !CONFIG_FAT_FS_READONLY)
|
||||
|
||||
/**
|
||||
* Enable f_forward function. Requires CONFIG_FAT_FS_TINY.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_FAT_USE_FORWARD 0
|
||||
#define _USE_FORWARD (CONFIG_FAT_USE_FORWARD && CONFIG_FAT_FS_TINY)
|
||||
|
||||
/**
|
||||
* Number of volumes (logical drives) to be used.
|
||||
* $WIZ$ type = "int"; min = 1; max = 255
|
||||
*/
|
||||
#define CONFIG_FAT_DRIVES 1
|
||||
#define _DRIVES CONFIG_FAT_DRIVES
|
||||
|
||||
/**
|
||||
* Maximum sector size to be handled. (512/1024/2048/4096).
|
||||
* 512 for memory card and hard disk, 1024 for floppy disk, 2048 for MO disk
|
||||
* $WIZ$ type = "int"; min = 512; max = 4096
|
||||
*/
|
||||
#define CONFIG_FAT_MAX_SS 512
|
||||
#define _MAX_SS CONFIG_FAT_MAX_SS
|
||||
|
||||
/**
|
||||
* When _MULTI_PARTITION is set to 0, each volume is bound to the same physical
|
||||
* drive number and can mount only first primaly partition. When it is set to 1,
|
||||
* each volume is tied to the partitions listed in Drives[].
|
||||
* $WIZ$ type = "boolean"
|
||||
* $WIZ$ supports = "False"
|
||||
*/
|
||||
#define CONFIG_FAT_MULTI_PARTITION 0
|
||||
#define _MULTI_PARTITION CONFIG_FAT_MULTI_PARTITION
|
||||
|
||||
/**
|
||||
* Specifies the OEM code page to be used on the target system.
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_FAT_CODE_PAGE 850
|
||||
#define _CODE_PAGE CONFIG_FAT_CODE_PAGE
|
||||
|
||||
/**
|
||||
* Support for long filenames. Enable only if you have a valid Microsoft license.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_FAT_USE_LFN 0
|
||||
#define _USE_LFN CONFIG_FAT_USE_LFN
|
||||
|
||||
/**
|
||||
* Maximum Long File Name length to handle.
|
||||
* $WIZ$ type = "int"; min = 8; max = 255
|
||||
*/
|
||||
#define CONFIG_FAT_MAX_LFN 255
|
||||
#define _MAX_LFN CONFIG_FAT_MAX_LFN
|
||||
|
||||
#endif /* CFG_FAT_H */
|
@ -1,51 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for flash25 module.
|
||||
*
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_FLASH25_H
|
||||
#define CFG_FLASH25_H
|
||||
|
||||
/**
|
||||
* Eeprom memory type.
|
||||
*
|
||||
*$WIZ$ type = "enum"
|
||||
*$WIZ$ value_list = "flash25_list"
|
||||
*/
|
||||
#define CONFIG_FLASH25 FLASH25_AT25F2048
|
||||
|
||||
#endif /* CFG_FALSH25_H */
|
||||
|
@ -1,65 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for formatted write module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_FORMATWR_H
|
||||
#define CFG_FORMATWR_H
|
||||
|
||||
/**
|
||||
* printf()-style formatter configuration.
|
||||
* $WIZ$ type = "enum"; value_list = "printf_list"
|
||||
*
|
||||
* \sa PRINTF_DISABLED
|
||||
* \sa PRINTF_NOMODIFIERS
|
||||
* \sa PRINTF_REDUCED
|
||||
* \sa PRINTF_NOFLOAT
|
||||
* \sa PRINTF_FULL
|
||||
*/
|
||||
#define CONFIG_PRINTF PRINTF_FULL
|
||||
|
||||
/**
|
||||
* Size of buffer to format "%" sequences in printf.
|
||||
*
|
||||
* Warning: no check on buffer size is done when formatting, be careful especially
|
||||
* with big numbers and %f formatting.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 4
|
||||
*/
|
||||
#define CONFIG_FRMWRI_BUFSIZE 134
|
||||
|
||||
#endif /* CFG_FORMATWR_H */
|
||||
|
@ -1,67 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for GFX module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_GFX_H
|
||||
#define CFG_GFX_H
|
||||
|
||||
/**
|
||||
* Enable line clipping algorithm.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_GFX_CLIPPING 1
|
||||
|
||||
/**
|
||||
* Enable text rendering in bitmaps.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_GFX_TEXT 1
|
||||
|
||||
/**
|
||||
* Enable virtual coordinate system.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_GFX_VCOORDS 1
|
||||
|
||||
/**
|
||||
* Select bitmap pixel format.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "bitmap_format"
|
||||
*/
|
||||
#define CONFIG_BITMAP_FMT BITMAP_FMT_PLANAR_V_LSB
|
||||
|
||||
#endif /* CFG_GFX_H */
|
||||
|
@ -1,51 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for hashtable module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_HASHTABLE_H
|
||||
#define CFG_HASHTABLE_H
|
||||
|
||||
/**
|
||||
* Enable/disable support to declare special hash tables which maintain a copy of the key internally instead of relying on the hook to extract it from the data.
|
||||
*
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_HT_OPTIONAL_INTERNAL_KEY 1
|
||||
|
||||
#endif /* CFG_HASHTABLE_H */
|
||||
|
||||
|
||||
|
@ -1,83 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for I2C module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_I2C_H
|
||||
#define CFG_I2C_H
|
||||
|
||||
/**
|
||||
*Comunication frequency.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_I2C_FREQ 100000UL
|
||||
|
||||
/**
|
||||
* I2C start timeout.
|
||||
* For how many milliseconds the i2c_start
|
||||
* should try to get an ACK before
|
||||
* returning error.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_I2C_START_TIMEOUT 100
|
||||
|
||||
/**
|
||||
* Check this to disable I2c deprecated API support.
|
||||
*
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_I2C_DISABLE_OLD_API 0
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define I2C_LOG_LEVEL LOG_LVL_INFO
|
||||
|
||||
/**
|
||||
* module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define I2C_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
#endif /* CFG_I2C_H */
|
||||
|
||||
|
@ -1,74 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2009 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for I2S module.
|
||||
*
|
||||
*
|
||||
* \author Luca Ottaviano <lottaviano@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_I2S_H
|
||||
#define CFG_I2S_H
|
||||
|
||||
/**
|
||||
* Length of each play buffer.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_PLAY_BUF_LEN 8192
|
||||
|
||||
/**
|
||||
* Sampling frequency of the audio file.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 32000
|
||||
* $WIZ$ max = 192000
|
||||
*/
|
||||
#define CONFIG_SAMPLE_FREQ 44100UL
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define I2S_LOG_LEVEL LOG_LVL_INFO
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define I2S_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
#endif /* CFG_I2S_H */
|
@ -1,48 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2009 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for ini reader module.
|
||||
*
|
||||
*
|
||||
* \author Luca Ottaviano <lottaviano@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_INI_READER_H
|
||||
#define CFG_INI_READER_H
|
||||
|
||||
/**
|
||||
* Maximum ini file line length (chars).
|
||||
* $WIZ$ type = "int"; min = 1
|
||||
*/
|
||||
#define CONFIG_INI_MAX_LINE_LEN 64
|
||||
|
||||
#endif /* CFG_INI_READER_H */
|
@ -1,58 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for keyboard module.
|
||||
*
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_KBD_H
|
||||
#define CFG_KBD_H
|
||||
|
||||
/// Keyboard polling method. $WIZ$ supports = "False"
|
||||
#define CONFIG_KBD_POLL KBD_POLL_SOFTINT
|
||||
|
||||
/// Enable keyboard event delivery to observers. $WIZ$ type = "boolean"
|
||||
#define CONFIG_KBD_OBSERVER 0
|
||||
|
||||
/// Enable key beeps. $WIZ$ type = "boolean"
|
||||
#define CONFIG_KBD_BEEP 0
|
||||
|
||||
/// Enable long pression handler for keys. $WIZ$ type = "boolean"
|
||||
#define CONFIG_KBD_LONGPRESS 0
|
||||
|
||||
/// Enable calling poor man's scheduler to be called inside kbd_peek. $WIZ$ type = "boolean"
|
||||
#define CONFIG_KBD_SCHED 0
|
||||
|
||||
#endif /* CFG_KBD_H */
|
||||
|
@ -1,61 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for keytag module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_KEYTAG_H
|
||||
#define CFG_KEYTAG_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define CONFIG_KEYTAG_LOG_LEVEL LOG_LVL_ERR
|
||||
/**
|
||||
* Module logging format.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define CONFIG_KEYTAG_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
/**
|
||||
* Max buffer lenght
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_TAG_MAX_LEN 14U
|
||||
|
||||
#endif /* CFG_KEYTAG_H */
|
||||
|
@ -1,61 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for KFile interface module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_KFILE_H
|
||||
#define CFG_KFILE_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define KFILE_LOG_LEVEL LOG_LVL_INFO
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define KFILE_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
/**
|
||||
* Enable the gets function with echo.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_KFILE_GETS 0
|
||||
|
||||
#endif /* CFG_KFILE_H */
|
@ -1,63 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2003, 2004, 2005, 2006, 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
* Copyright 2001 Bernie Innocenti <bernie@codewiz.org>
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Displaytech 32122A LCD driver configuration file.
|
||||
*
|
||||
* \author Bernie Innocenti <bernie@codewiz.org>
|
||||
* \author Stefano Fedrigo <aleph@develer.com>
|
||||
*
|
||||
*/
|
||||
#ifndef CFG_LCD_32122A_H
|
||||
#define CFG_LCD_32122A_H
|
||||
|
||||
/**
|
||||
* Enable soft interrupt to refresh the LCD.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_LCD_SOFTINT_REFRESH 0
|
||||
|
||||
/**
|
||||
* Enable wait macro when display is busy.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_LCD_WAIT 0
|
||||
|
||||
/**
|
||||
* Display refresh time 32122a.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 0
|
||||
*/
|
||||
#define CONFIG_LCD_REFRESH 100
|
||||
|
||||
#endif /* CFG_LCD_32122A_H */
|
||||
|
@ -1,69 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for lcd display module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_LCD_H
|
||||
#define CFG_LCD_H
|
||||
|
||||
/**
|
||||
* Use 4 bit addressing mode.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_LCD_4BIT 0
|
||||
|
||||
/**
|
||||
* Use a table to speed up LCD memory addressing.
|
||||
* This will use about 100 bytes of RAM.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_LCD_ADDRESS_FAST 1
|
||||
|
||||
/**
|
||||
* Number of columns in LCD display.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "lcd_hd44_cols"
|
||||
*/
|
||||
#define CONFIG_LCD_COLS LCD_HD44_COLS_16
|
||||
|
||||
/**
|
||||
* Number of rows in LCD display.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "lcd_hd44_rows"
|
||||
*/
|
||||
#define CONFIG_LCD_ROWS LCD_HD44_ROWS_2
|
||||
|
||||
#endif /* CFG_LCD_H */
|
||||
|
@ -1,80 +0,0 @@
|
||||
/**
|
||||
* \file cfg_led_7seg.h
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for led 7 segment display.
|
||||
*
|
||||
* \author Fabio Bizzi <fbizzi@bizzi.org>
|
||||
*
|
||||
* \addtogroup SevenSegDisplay 7 Segments LED Displays Driver
|
||||
* \{
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CFG_LED_7SEG_H
|
||||
#define CFG_LED_7SEG_H
|
||||
|
||||
/**
|
||||
* Use a Common Cathode display.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_LED_7SEG_CCAT 0
|
||||
|
||||
/**
|
||||
* Number of digit present in the LED display.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
* $WIZ$ max = 8
|
||||
*/
|
||||
#define CONFIG_LED_7SEG_DIGIT 4
|
||||
|
||||
/**
|
||||
* Max lenght of the string to be displayed.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 16
|
||||
* $WIZ$ max = 255
|
||||
*/
|
||||
#define CONFIG_LED_7SEG_STRLEN 255
|
||||
|
||||
/**
|
||||
* Default scrolling speed (ms * CONFIG_LED_7SEG_RTIME).
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_LED_7SEG_SSPEED 10
|
||||
|
||||
/**
|
||||
* Default refresh time (ms).
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_LED_7SEG_RTIME 5
|
||||
|
||||
#endif /* CFG_LED_7SEG_H */
|
||||
/** \} */ //defgroup drivers
|
||||
|
@ -1,57 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for the LM75 sensor temperature.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_LM75_H
|
||||
#define CFG_LM75_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define LM75_LOG_LEVEL LOG_LVL_WARN
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define LM75_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
#endif /* CFG_AX25_H */
|
File diff suppressed because it is too large
Load Diff
@ -1,53 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for MD2 module.
|
||||
*
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_MD2_H
|
||||
#define CFG_MD2_H
|
||||
|
||||
/**
|
||||
* Size of block for MD2 algorithm.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 2
|
||||
*/
|
||||
#define CONFIG_MD2_BLOCK_LEN 16
|
||||
|
||||
/// Use standard permutation in MD2 algorithm. $WIZ$ type = "boolean"
|
||||
#define CONFIG_MD2_STD_PERM 0
|
||||
|
||||
#endif /* CFG_MD2_H */
|
||||
|
@ -1,67 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for Menu module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_MENU_H
|
||||
#define CFG_MENU_H
|
||||
|
||||
/**
|
||||
* Enable button bar behind menus
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_MENU_MENUBAR 0
|
||||
|
||||
/**
|
||||
* Level Edit Timeout
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_LEVELEDIT_TIMEOUT 0
|
||||
|
||||
/**
|
||||
* Menu timeout
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_MENU_TIMEOUT 0
|
||||
|
||||
/**
|
||||
* Enable smooth scrolling in menus
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_MENU_SMOOTH 1
|
||||
|
||||
|
||||
#endif /* CFG_MENU_H */
|
||||
|
@ -1,47 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/)
|
||||
* Copyright 1999, 2000, 2001, 2008 Bernie Innocenti <bernie@codewiz.org>
|
||||
* -->
|
||||
*
|
||||
* \brief Kernel monitor configuration parameters
|
||||
*
|
||||
* \author Bernie Innocenti <bernie@codewiz.org>
|
||||
*/
|
||||
|
||||
#ifndef CFG_MONITOR_H
|
||||
#define CFG_MONITOR_H
|
||||
|
||||
/**
|
||||
* Process monitor.
|
||||
* $WIZ$ type = "autoenabled"
|
||||
*/
|
||||
#define CONFIG_KERN_MONITOR 0
|
||||
|
||||
#endif /* CFG_MONITOR_H */
|
@ -1,111 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2011 Develer S.r.l. (http://www.develer.com/)
|
||||
* -->
|
||||
*
|
||||
* \author Stefano Fedrigo <aleph@develer.com>
|
||||
*
|
||||
* \brief Configuration file for NAND driver module.
|
||||
*/
|
||||
|
||||
#ifndef CFG_NAND_H
|
||||
#define CFG_NAND_H
|
||||
|
||||
/**
|
||||
* Page data size
|
||||
*
|
||||
* Size of the data section of a programmable page in bytes.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_NAND_DATA_SIZE 2048
|
||||
|
||||
/**
|
||||
* Page spare area size
|
||||
*
|
||||
* Size of the spare section of a programmable page in bytes.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_NAND_SPARE_SIZE 64
|
||||
|
||||
/**
|
||||
* Pages per block
|
||||
*
|
||||
* Number of pages in a erase block.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_NAND_PAGES_PER_BLOCK 64
|
||||
|
||||
/**
|
||||
* Number of blocks
|
||||
*
|
||||
* Total number of erase blocks in one NAND chip.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_NAND_NUM_BLOCK 2048
|
||||
|
||||
/**
|
||||
* Number of reserved blocks
|
||||
*
|
||||
* Blocks reserved for remapping defective NAND blocks.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_NAND_NUM_REMAP_BLOCKS 128
|
||||
|
||||
/**
|
||||
* NAND operations timeout
|
||||
*
|
||||
* How many milliseconds the cpu waits for
|
||||
* completion of NAND operations.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_NAND_TMOUT 100
|
||||
|
||||
/**
|
||||
* Module logging level
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define CONFIG_NAND_LOG_LEVEL LOG_LVL_WARN
|
||||
|
||||
/**
|
||||
* Module logging format
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define CONFIG_NAND_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
#endif /* CFG_NAND_H */
|
@ -1,85 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for NMEA module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_NMEA_H
|
||||
#define CFG_NMEA_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define NMEA_LOG_LEVEL LOG_LVL_ERR
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define NMEA_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
|
||||
/**
|
||||
* Maximum number of sentence parsers supported.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_NMEAP_MAX_SENTENCES 8
|
||||
|
||||
/**
|
||||
* Max length of a complete sentence. The standard says 82 bytes, but its probably
|
||||
* better to go at least 128 since some units don't adhere to the 82 bytes
|
||||
* especially for proprietary sentences.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_NMEAP_MAX_SENTENCE_LENGTH 255
|
||||
|
||||
/**
|
||||
* Max tokens in one sentence. 24 is enough for any standard sentence.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_NMEAP_MAX_TOKENS 24
|
||||
|
||||
#endif /* CFG_NMEA_H */
|
||||
|
@ -1,54 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for NTC module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_NTC_H
|
||||
#define CFG_NTC_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define CONFIG_NTC_LOG_LEVEL LOG_LVL_INFO
|
||||
/**
|
||||
* Module logging format.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define CONFIG_NTC_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
#endif /* CFG_NTC_H */
|
@ -1,66 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for parser module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_PARSER_H
|
||||
#define CFG_PARSER_H
|
||||
|
||||
/**
|
||||
* Max number of arguments and results for each command
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 0
|
||||
*/
|
||||
#define CONFIG_PARSER_MAX_ARGS 4
|
||||
|
||||
/**
|
||||
* Max number of commands
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 8
|
||||
*/
|
||||
#define CONFIG_MAX_COMMANDS_NUMBER 16
|
||||
|
||||
/**
|
||||
* Enable compatibility behaviour.
|
||||
*
|
||||
* Skip the first word from incoming commands. Don't enable in new projects.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_ENABLE_COMPAT_BEHAVIOUR 1
|
||||
|
||||
#endif /* CFG_PARSER_H */
|
||||
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for phase module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_PHASE_H
|
||||
#define CFG_PHASE_H
|
||||
|
||||
/**
|
||||
* Max value of the duty cycle on triac.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_TRIAC_MAX_DUTY 100
|
||||
|
||||
/**
|
||||
* Max value of the triac power.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_TRIAC_MAX_POWER 100
|
||||
|
||||
#endif /* CFG_PHASE_H */
|
@ -1,56 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2009 Develer S.r.l. (http://www.develer.com/)
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for PWM module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_PID_H
|
||||
#define CFG_PID_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define PID_LOG_LEVEL LOG_LVL_WARN
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define PID_LOG_FORMAT LOG_FMT_VERBOSE
|
||||
|
||||
#endif /* CFG_PID_H */
|
@ -1,71 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for pocketbus module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_POCKETBUS_H
|
||||
#define CFG_POCKETBUS_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define POCKETBUS_LOG_LEVEL LOG_LVL_ERR
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define POCKETBUS_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
|
||||
/**
|
||||
*Buffer len for pockebus protocol.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 2
|
||||
*/
|
||||
#define CONFIG_POCKETBUS_BUFLEN 128
|
||||
|
||||
/**
|
||||
* Command replay timeout in milliseconds.
|
||||
* $WIZ$ type = "int"
|
||||
*/
|
||||
#define CONFIG_POCKETBUS_CMD_REPLY_TIMEOUT 50
|
||||
|
||||
#endif /* CFG_POCKETBUS_H */
|
@ -1,113 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/)
|
||||
* Copyright 1999, 2000, 2001, 2008 Bernie Innocenti <bernie@codewiz.org>
|
||||
* -->
|
||||
*
|
||||
* \brief Kernel configuration parameters
|
||||
*
|
||||
* \author Bernie Innocenti <bernie@codewiz.org>
|
||||
*/
|
||||
|
||||
#ifndef CFG_PROC_H
|
||||
#define CFG_PROC_H
|
||||
|
||||
/**
|
||||
* Enable the multithreading kernel.
|
||||
*
|
||||
* $WIZ$ type = "autoenabled"
|
||||
*/
|
||||
#define CONFIG_KERN 0
|
||||
|
||||
/**
|
||||
* Kernel interrupt supervisor. WARNING: Experimental, still incomplete!
|
||||
* $WIZ$ type = "boolean"
|
||||
* $WIZ$ supports = "False"
|
||||
*/
|
||||
#define CONFIG_KERN_IRQ 0
|
||||
|
||||
/**
|
||||
* Preemptive process scheduling.
|
||||
*
|
||||
* $WIZ$ type = "boolean"
|
||||
* $WIZ$ conditional_deps = "timer"
|
||||
*/
|
||||
#define CONFIG_KERN_PREEMPT 0
|
||||
|
||||
/**
|
||||
* Time sharing quantum (a prime number prevents interference effects) [ms].
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_KERN_QUANTUM 11
|
||||
|
||||
/**
|
||||
* Priority-based scheduling policy.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_KERN_PRI 0
|
||||
|
||||
/**
|
||||
* Priority-inheritance protocol.
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_KERN_PRI_INHERIT 0
|
||||
|
||||
/**
|
||||
* Dynamic memory allocation for processes.
|
||||
* $WIZ$ type = "boolean"
|
||||
* $WIZ$ conditional_deps = "heap"
|
||||
*/
|
||||
#define CONFIG_KERN_HEAP 0
|
||||
|
||||
/**
|
||||
* Size of the dynamic memory pool used by processes.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 0
|
||||
*/
|
||||
#define CONFIG_KERN_HEAP_SIZE 2048L
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define KERN_LOG_LEVEL LOG_LVL_ERR
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define KERN_LOG_FORMAT LOG_FMT_VERBOSE
|
||||
|
||||
#endif /* CFG_PROC_H */
|
@ -1,64 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for PWM module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_PWM_H
|
||||
#define CFG_PWM_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define PWM_LOG_LEVEL LOG_LVL_INFO
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define PWM_LOG_FORMAT LOG_FMT_VERBOSE
|
||||
|
||||
/**
|
||||
* Enable the OLD pwm API.
|
||||
* Not recommended for new projects.
|
||||
*
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CFG_PWM_ENABLE_OLD_API 1
|
||||
|
||||
#endif /* CFG_PWM_H */
|
@ -1,115 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file Ramp algorithm module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_RAMP_H
|
||||
#define CFG_RAMP_H
|
||||
|
||||
/**
|
||||
* Define whether the ramp will use floating point calculation within ramp_evaluate().
|
||||
* Otherwise, a less precise fixed point version will be used, which is faster on
|
||||
* platforms which do no support floating point operations.
|
||||
*
|
||||
* \note Floating point operations will be always done within ramp_compute() to
|
||||
* precalculate values, so there has to be at least a floating point emulation support.
|
||||
*
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define RAMP_USE_FLOATING_POINT 0
|
||||
|
||||
|
||||
#if !RAMP_USE_FLOATING_POINT
|
||||
|
||||
/**
|
||||
* Number of least-significant bits which are stripped away during ramp evaluation.
|
||||
* This setting allows to specify larger ramps at the price of less precision.
|
||||
*
|
||||
* The maximum ramp size allowed is 2^(24 + RAMP_CLOCK_SHIFT_PRECISION), in clocks.
|
||||
* For instance, using RAMP_CLOCK_SHIFT_PRECISION 1, and a 8x prescaler, the maximum
|
||||
* length of a ramp is about 6.7 secs. Raising RAMP_CLOCK_SHIFT_PRECISION to 2
|
||||
* brings the maximum length to 13.4 secs, at the price of less precision.
|
||||
*
|
||||
* ramp_compute() will check that the length is below the maximum allowed through
|
||||
* a runtime assertion.
|
||||
*
|
||||
* \note This macro is used only for the fixed-point version of the ramp.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 0
|
||||
* $WIZ$ max = 32
|
||||
*/
|
||||
#define RAMP_CLOCK_SHIFT_PRECISION 2
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Negative pulse width for ramp.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define RAMP_PULSE_WIDTH 50
|
||||
|
||||
/**
|
||||
* Default ramp time (microsecs).
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1000
|
||||
*/
|
||||
#define RAMP_DEF_TIME 6000000UL
|
||||
/**
|
||||
* Default ramp maxfreq (Hz).
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define RAMP_DEF_MAXFREQ 5000
|
||||
/**
|
||||
* Default ramp minfreq (Hz).
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define RAMP_DEF_MINFREQ 200
|
||||
/**
|
||||
* Default ramp powerrun (deciampere).
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 0
|
||||
*/
|
||||
#define RAMP_DEF_POWERRUN 10
|
||||
/**
|
||||
* Default ramp poweridle (Hz).
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 0
|
||||
*/
|
||||
#define RAMP_DEF_POWERIDLE 1
|
||||
|
||||
#endif /* CFG_RAMP_H */
|
@ -1,75 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2009 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file Secure Digital module.
|
||||
*
|
||||
*
|
||||
* \author Francesco Sacchi <batt@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_SD_H
|
||||
#define CFG_SD_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define SD_LOG_LEVEL LOG_LVL_ERR
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define SD_LOG_FORMAT LOG_FMT_VERBOSE
|
||||
|
||||
|
||||
/**
|
||||
* Enable autoassignment of SD driver to disk drive number 0 of FatFs module.
|
||||
* $WIZ$ type = "boolean"
|
||||
* $WIZ$ conditional_deps = "fat"
|
||||
*/
|
||||
#define CONFIG_SD_AUTOASSIGN_FAT 1
|
||||
|
||||
/**
|
||||
* Enable backward compatibility for sd_init().
|
||||
* If enabled, sd_init() will allocate internally an Sd context,
|
||||
* otherwise sd_init() will need the context to be passed explicitly.
|
||||
*
|
||||
* $WIZ$ type = "boolean"
|
||||
*/
|
||||
#define CONFIG_SD_OLD_INIT 1
|
||||
|
||||
#endif /* CFG_SD_H */
|
@ -1,47 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/)
|
||||
* Copyright 1999, 2000, 2001, 2008 Bernie Innocenti <bernie@codewiz.org>
|
||||
* -->
|
||||
*
|
||||
* \brief Kernel semaphores configuration parameters.
|
||||
*
|
||||
* \author Bernie Innocenti <bernie@codewiz.org>
|
||||
*/
|
||||
|
||||
#ifndef CFG_SEM_H
|
||||
#define CFG_SEM_H
|
||||
|
||||
/**
|
||||
* Re-entrant mutual exclusion primitives.
|
||||
* $WIZ$ type = "autoenabled"
|
||||
*/
|
||||
#define CONFIG_KERN_SEMAPHORES 0
|
||||
|
||||
#endif /* CFG_SEM_H */
|
@ -1,47 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/)
|
||||
* Copyright 1999, 2000, 2001, 2008 Bernie Innocenti <bernie@codewiz.org>
|
||||
* -->
|
||||
*
|
||||
* \brief Kernel signals configuration parameters
|
||||
*
|
||||
* \author Bernie Innocenti <bernie@codewiz.org>
|
||||
*/
|
||||
|
||||
#ifndef CFG_SIGNAL_H
|
||||
#define CFG_SIGNAL_H
|
||||
|
||||
/**
|
||||
* Inter-process signals.
|
||||
* $WIZ$ type = "autoenabled"
|
||||
*/
|
||||
#define CONFIG_KERN_SIGNALS 0
|
||||
|
||||
#endif /* CFG_SIGNAL_H */
|
@ -1,51 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for SPI bitbang module.
|
||||
*
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_SPI_BITBANG_H
|
||||
#define CFG_SPI_BITBANG_H
|
||||
|
||||
/**
|
||||
* Set data order for emulated SPI.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "ordet_bit_list"
|
||||
*/
|
||||
#define CONFIG_SPI_DATAORDER SPI_LSB_FIRST
|
||||
|
||||
#endif /* CFG_SPI_BITBANG_H */
|
||||
|
@ -1,60 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for spi dma module.
|
||||
*
|
||||
*
|
||||
* \author Francesco Sacchi <batt@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_SPI_DMA_H
|
||||
#define CFG_SPI_DMA_H
|
||||
|
||||
|
||||
/**
|
||||
* Max size received for each DMA transfer [bytes].
|
||||
* Longer buffers will be split in two or more transfers of this size.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_SPI_DMA_MAX_RX 512
|
||||
|
||||
|
||||
/**
|
||||
* Default transmit timeout (ms). Set to -1 to disable timeout support.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = -1
|
||||
*/
|
||||
#define CONFIG_SPI_DMA_TX_TIMEOUT -1
|
||||
|
||||
|
||||
#endif /* CFG_SER_H */
|
@ -1,69 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for stepper motor module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_STEPPER_H
|
||||
#define CFG_STEPPER_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define STEPPER_LOG_LEVEL LOG_LVL_INFO
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define STEPPER_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
/**
|
||||
* Max number of the stepper motor.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_NUM_STEPPER_MOTORS 6
|
||||
|
||||
/**
|
||||
* Max number of the timer usable on target to drive stepper motor.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_TC_STEPPER_MAX_NUM 6
|
||||
|
||||
#endif /* CFG_STEPPER_H */
|
@ -1,50 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2009 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for the TAS5706A module.
|
||||
*
|
||||
* \author Luca Ottaviano <lottaviano@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_TAS5706A_H
|
||||
#define CFG_TAS5706A_H
|
||||
|
||||
/**
|
||||
* Maximum output volume for TAS chip [dB].
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = -100
|
||||
* $WIZ$ max = 24
|
||||
*/
|
||||
#define CONFIG_TAS_MAX_VOL -39
|
||||
|
||||
#endif /* CFG_TAS5706A_H */
|
@ -1,20 +0,0 @@
|
||||
#ifndef CFG_TFTP_H
|
||||
#define CFG_TFTP_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define TFTP_LOG_LEVEL LOG_LVL_WARN
|
||||
|
||||
/**
|
||||
* Module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define TFTP_LOG_FORMAT LOG_FMT_VERBOSE
|
||||
|
||||
#endif /* CFG_TFTP_H */
|
@ -1,71 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for thermo module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_THERMO_H
|
||||
#define CFG_THERMO_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define CONFIG_THERMO_LOG_LEVEL LOG_LVL_ERR
|
||||
/**
|
||||
* Module logging format.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define CONFIG_THERMO_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
|
||||
/**
|
||||
* Interval at which thermo control is performed [ms].
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_THERMO_INTERVAL_MS 100
|
||||
|
||||
/**
|
||||
* Number of different samples we interpolate over to get the hifi temperature.
|
||||
*
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_THERMO_HIFI_NUM_SAMPLES 10
|
||||
|
||||
#endif /* CFG_THERMO_H */
|
@ -1,85 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \author Andrea Righi <arighi@develer.com>
|
||||
*
|
||||
* \brief Configuration file for the USB driver module
|
||||
*/
|
||||
|
||||
#ifndef CFG_USB_H
|
||||
#define CFG_USB_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define USB_LOG_LEVEL LOG_LVL_INFO
|
||||
|
||||
/**
|
||||
* module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define USB_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
/**
|
||||
* Size of the USB buffer used for endpoint transfers [bytes].
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 2
|
||||
*/
|
||||
#define CONFIG_USB_BUFSIZE 64
|
||||
|
||||
/**
|
||||
* Maximum number of USB device interfaces (default = 1).
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_USB_INTERFACE_MAX 1
|
||||
|
||||
/**
|
||||
* Maximum number of allocated endpoints (0 = auto).
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 0
|
||||
*/
|
||||
#define CONFIG_USB_EP_MAX 0
|
||||
|
||||
/**
|
||||
* Maximum packet size of the control endpoint 0 [bytes].
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 8
|
||||
*/
|
||||
#define CONFIG_EP0_MAX_SIZE 8
|
||||
|
||||
#endif /* CFG_USB_H */
|
@ -1,78 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \author Andrea Righi <arighi@develer.com>
|
||||
*
|
||||
* \brief Configuration file for the usbkbd driver module
|
||||
*/
|
||||
|
||||
#ifndef CFG_USBKBD_H
|
||||
#define CFG_USBKBD_H
|
||||
|
||||
/**
|
||||
* Enable the usbkbd module.
|
||||
*
|
||||
* $WIZ$ type = "autoenabled"
|
||||
*/
|
||||
#define CONFIG_USBKBD 0
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define USB_KEYBOARD_LOG_LEVEL LOG_LVL_INFO
|
||||
|
||||
/**
|
||||
* module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define USB_KEYBOARD_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
/**
|
||||
* USB vendor ID (please change this in your project, using a valid ID number!).
|
||||
*
|
||||
* $WIZ$ type = "hex"
|
||||
*/
|
||||
#define USB_KEYBOARD_VENDOR_ID 0x046d
|
||||
|
||||
/**
|
||||
* USB product ID (please change this in your project, using a valid ID number!).
|
||||
*
|
||||
* $WIZ$ type = "hex"
|
||||
*/
|
||||
#define USB_KEYBOARD_PRODUCT_ID 0xffff
|
||||
|
||||
#endif /* CFG_USB_KEYBOARD_H */
|
@ -1,78 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \author Andrea Righi <arighi@develer.com>
|
||||
*
|
||||
* \brief Configuration file for the usbmouse driver module
|
||||
*/
|
||||
|
||||
#ifndef CFG_USBMOUSE_H
|
||||
#define CFG_USBMOUSE_H
|
||||
|
||||
/**
|
||||
* Enable the usbmouse module.
|
||||
*
|
||||
* $WIZ$ type = "autoenabled"
|
||||
*/
|
||||
#define CONFIG_USBMOUSE 0
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define USB_MOUSE_LOG_LEVEL LOG_LVL_INFO
|
||||
|
||||
/**
|
||||
* module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define USB_MOUSE_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
/**
|
||||
* USB vendor ID (please change this in your project, using a valid ID number!).
|
||||
*
|
||||
* $WIZ$ type = "hex"
|
||||
*/
|
||||
#define USB_MOUSE_VENDOR_ID 0xffff
|
||||
|
||||
/**
|
||||
* USB product ID (please change this in your project, using a valid ID number!).
|
||||
*
|
||||
* $WIZ$ type = "hex"
|
||||
*/
|
||||
#define USB_MOUSE_PRODUCT_ID 0x0000
|
||||
|
||||
#endif /* CFG_USBMOUSE_H */
|
@ -1,78 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \author Andrea Righi <arighi@develer.com>
|
||||
*
|
||||
* \brief Configuration file for the USB serial driver module
|
||||
*/
|
||||
|
||||
#ifndef CFG_USBSER_H
|
||||
#define CFG_USBSER_H
|
||||
|
||||
/**
|
||||
* Enable the usb-serial module.
|
||||
*
|
||||
* $WIZ$ type = "autoenabled"
|
||||
*/
|
||||
#define CONFIG_USBSER 0
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define USB_SERIAL_LOG_LEVEL LOG_LVL_INFO
|
||||
|
||||
/**
|
||||
* module logging format.
|
||||
*
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define USB_SERIAL_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
/**
|
||||
* USB vendor ID (please change this in your project, using a valid ID number!).
|
||||
*
|
||||
* $WIZ$ type = "hex"
|
||||
*/
|
||||
#define USB_SERIAL_VENDOR_ID 0x05f9
|
||||
|
||||
/**
|
||||
* USB product ID (please change this in your project, using a valid ID number!).
|
||||
*
|
||||
* $WIZ$ type = "hex"
|
||||
*/
|
||||
#define USB_SERIAL_PRODUCT_ID 0xffff
|
||||
|
||||
#endif /* CFG_USBSER_H */
|
@ -1,47 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for watchdog module.
|
||||
*
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_WDT_H
|
||||
#define CFG_WDT_H
|
||||
|
||||
/// Enable watchdog timer. $WIZ$ type = "autoenabled"
|
||||
#define CONFIG_WATCHDOG 0
|
||||
|
||||
#endif /* CFG_WDT_H */
|
||||
|
||||
|
@ -1,79 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief Configuration file for xmodem module.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef CFG_XMODEM_H
|
||||
#define CFG_XMODEM_H
|
||||
|
||||
/**
|
||||
* Module logging level.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_level"
|
||||
*/
|
||||
#define CONFIG_XMODEM_LOG_LEVEL LOG_LVL_ERR
|
||||
/**
|
||||
* Module logging format.
|
||||
* $WIZ$ type = "enum"
|
||||
* $WIZ$ value_list = "log_format"
|
||||
*/
|
||||
#define CONFIG_XMODEM_LOG_FORMAT LOG_FMT_TERSE
|
||||
|
||||
|
||||
/// Enable Rx. $WIZ$ type = "boolean"
|
||||
#define CONFIG_XMODEM_RECV 1
|
||||
|
||||
/// Enable TX. $WIZ$ type = "boolean"
|
||||
#define CONFIG_XMODEM_SEND 1
|
||||
|
||||
/// Allow a Rx/Tx of 1Kbyte block. $WIZ$ type = "boolean"
|
||||
#define CONFIG_XMODEM_1KCRC 1
|
||||
|
||||
/**
|
||||
* Max retries before giving up.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_XMODEM_MAXRETRIES 15
|
||||
|
||||
/**
|
||||
* Max retries before switching to BCC.
|
||||
* $WIZ$ type = "int"
|
||||
* $WIZ$ min = 1
|
||||
*/
|
||||
#define CONFIG_XMODEM_MAXCRCRETRIES 7
|
||||
|
||||
#endif /* CFG_XMODEM_H */
|
||||
|
@ -1,54 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2007 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Low-level ADC module for ARM (inplementation).
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
* This module is automatically included so no need to include
|
||||
* in test list.
|
||||
* notest: arm
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef WIZ_AUTOGEN
|
||||
#warning This file is deprecated, you should use adc_at91.c
|
||||
|
||||
#include <cpu/detect.h>
|
||||
|
||||
#if CPU_ARM_AT91
|
||||
#include "adc_at91.c"
|
||||
/*#elif Add other ARM families here */
|
||||
#else
|
||||
#error Unknown CPU
|
||||
#endif
|
||||
#endif /* WIZ_AUTOGEN */
|
@ -1,46 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2007 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Low-level ADC module for ARM (interface).
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cpu/detect.h>
|
||||
|
||||
#if CPU_ARM_AT91
|
||||
#include "adc_at91.h"
|
||||
/*#elif Add other ARM families here */
|
||||
#else
|
||||
#error Unknown CPU
|
||||
#endif
|
@ -1,210 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief ADC hardware-specific implementation
|
||||
*
|
||||
* This ADC module should be use both whit kernel or none.
|
||||
* If you are using a kernel, the adc drive does not wait the finish of
|
||||
* conversion but use a singal every time a required conversion are
|
||||
* ended. This signal wake up a process that return a result of
|
||||
* conversion. Otherwise, if you not use a kernl, this module wait
|
||||
* whit a loop the finishing of conversion.
|
||||
*
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "adc_at91.h"
|
||||
|
||||
#include <cpu/irq.h>
|
||||
|
||||
#include "cfg/cfg_adc.h"
|
||||
#include "cfg/cfg_proc.h"
|
||||
#include "cfg/cfg_signal.h"
|
||||
#include <cfg/macros.h>
|
||||
#include <cfg/compiler.h>
|
||||
|
||||
// Define log settings for cfg/log.h.
|
||||
#define LOG_LEVEL ADC_LOG_LEVEL
|
||||
#define LOG_FORMAT ADC_LOG_FORMAT
|
||||
#include <cfg/log.h>
|
||||
|
||||
#include <drv/adc.h>
|
||||
|
||||
#include <io/arm.h>
|
||||
|
||||
#if CONFIG_KERN
|
||||
#include <cfg/module.h>
|
||||
#include <kern/proc.h>
|
||||
#include <kern/signal.h>
|
||||
|
||||
|
||||
#if !CONFIG_KERN_SIGNALS
|
||||
#error Signals must be active to use ADC with kernel
|
||||
#endif
|
||||
|
||||
/* Signal adc convertion end */
|
||||
#define SIG_ADC_COMPLETE SIG_USER0
|
||||
|
||||
/* ADC waiting process */
|
||||
static struct Process *adc_process;
|
||||
|
||||
/**
|
||||
* ADC ISR.
|
||||
* Simply signal the adc process that convertion is complete.
|
||||
*/
|
||||
static DECLARE_ISR(adc_conversion_end_irq)
|
||||
{
|
||||
sig_post(adc_process, SIG_ADC_COMPLETE);
|
||||
|
||||
/* Inform hw that we have served the IRQ */
|
||||
AIC_EOICR = 0;
|
||||
}
|
||||
|
||||
static void adc_enable_irq(void)
|
||||
{
|
||||
|
||||
// Disable all interrupt
|
||||
ADC_IDR = 0xFFFFFFFF;
|
||||
|
||||
//Register interrupt vector
|
||||
AIC_SVR(ADC_ID) = adc_conversion_end_irq;
|
||||
AIC_SMR(ADC_ID) = AIC_SRCTYPE_INT_EDGE_TRIGGERED;
|
||||
AIC_IECR = BV(ADC_ID);
|
||||
|
||||
//Enable data ready irq
|
||||
ADC_IER = BV(ADC_DRDY);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_KERN */
|
||||
|
||||
|
||||
/**
|
||||
* Select mux channel \a ch.
|
||||
* \todo only first 8 channels are selectable!
|
||||
*/
|
||||
void adc_hw_select_ch(uint8_t ch)
|
||||
{
|
||||
//Disable all channels
|
||||
ADC_CHDR = ADC_CH_MASK;
|
||||
//Enable select channel
|
||||
ADC_CHER = BV(ch);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Start an ADC convertion.
|
||||
* If a kernel is present, preempt until convertion is complete, otherwise
|
||||
* a busy wait on ADC_DRDY bit is done.
|
||||
*/
|
||||
uint16_t adc_hw_read(void)
|
||||
{
|
||||
#if CONFIG_KERN
|
||||
/* Ensure ADC is not already in use by another process */
|
||||
ASSERT(adc_process == NULL);
|
||||
adc_process = proc_current();
|
||||
#endif
|
||||
|
||||
// Start convertion
|
||||
ADC_CR = BV(ADC_START);
|
||||
|
||||
#if CONFIG_KERN
|
||||
// Ensure IRQs enabled.
|
||||
IRQ_ASSERT_ENABLED();
|
||||
sig_wait(SIG_ADC_COMPLETE);
|
||||
|
||||
/* Prevent race condition in case of preemptive kernel */
|
||||
uint16_t ret = ADC_LCDR;
|
||||
MEMORY_BARRIER;
|
||||
adc_process = NULL;
|
||||
return ret;
|
||||
#else
|
||||
//Wait in polling until is done
|
||||
while (!(ADC_SR & BV(ADC_DRDY)));
|
||||
|
||||
//Return the last converted data
|
||||
return(ADC_LCDR);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Init ADC hardware.
|
||||
*/
|
||||
void adc_hw_init(void)
|
||||
{
|
||||
//Init ADC pins.
|
||||
ADC_INIT_PINS();
|
||||
|
||||
/*
|
||||
* Set adc mode register:
|
||||
* - Disable hardware trigger and enable software trigger.
|
||||
* - Select normal mode.
|
||||
* - Set ADC_BITS bit convertion resolution.
|
||||
*
|
||||
* \{
|
||||
*/
|
||||
ADC_MR = 0;
|
||||
#if ADC_BITS == 10
|
||||
ADC_MR &= ~BV(ADC_LOWRES);
|
||||
#elif ADC_BITS == 8
|
||||
ADC_MR |= BV(ADC_LOWRES);
|
||||
#else
|
||||
#error No select bit resolution is supported to this CPU
|
||||
#endif
|
||||
/* \} */
|
||||
|
||||
LOG_INFO("Computed ADC_CLOCK %ld\n", ADC_COMPUTED_CLOCK);
|
||||
LOG_INFO("prescaler[%ld], stup[%ld], shtim[%ld]\n",ADC_COMPUTED_PRESCALER, ADC_COMPUTED_STARTUPTIME, ADC_COMPUTED_SHTIME);
|
||||
|
||||
|
||||
//Apply computed prescaler value
|
||||
ADC_MR &= ~ADC_PRESCALER_MASK;
|
||||
ADC_MR |= ((ADC_COMPUTED_PRESCALER << ADC_PRESCALER_SHIFT) & ADC_PRESCALER_MASK);
|
||||
LOG_INFO("prescaler[%ld]\n", (ADC_COMPUTED_PRESCALER << ADC_PRESCALER_SHIFT) & ADC_PRESCALER_MASK);
|
||||
|
||||
//Apply computed start up time
|
||||
ADC_MR &= ~ADC_STARTUP_MASK;
|
||||
ADC_MR |= ((ADC_COMPUTED_STARTUPTIME << ADC_STARTUP_SHIFT) & ADC_STARTUP_MASK);
|
||||
LOG_INFO("sttime[%ld]\n", (ADC_COMPUTED_STARTUPTIME << ADC_STARTUP_SHIFT) & ADC_STARTUP_MASK);
|
||||
|
||||
//Apply computed sample and hold time
|
||||
ADC_MR &= ~ADC_SHTIME_MASK;
|
||||
ADC_MR |= ((ADC_COMPUTED_SHTIME << ADC_SHTIME_SHIFT) & ADC_SHTIME_MASK);
|
||||
LOG_INFO("shtime[%ld]\n", (ADC_COMPUTED_SHTIME << ADC_SHTIME_SHIFT) & ADC_SHTIME_MASK);
|
||||
|
||||
#if CONFIG_KERN
|
||||
//Register and enable irq for adc.
|
||||
adc_enable_irq();
|
||||
#endif
|
||||
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2008 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief ADC hardware-specific definition
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef DRV_ADC_AT91_H
|
||||
#define DRV_ADC_AT91_H
|
||||
|
||||
#include <hw/hw_cpufreq.h>
|
||||
|
||||
#include "cfg/cfg_adc.h"
|
||||
|
||||
#include <cfg/compiler.h>
|
||||
|
||||
/**
|
||||
* ADC config define.
|
||||
*/
|
||||
#define ADC_MUX_MAXCH 8 //Max number of channel for ADC.
|
||||
#define ADC_BITS 10 //Bit resolution for ADC converter.
|
||||
|
||||
/**
|
||||
* Macro for computing correct value to write into ADC
|
||||
* register.
|
||||
*/
|
||||
#define ADC_COMPUTED_PRESCALER (DIV_ROUNDUP(CPU_FREQ, 2 * CONFIG_ADC_CLOCK) - 1)
|
||||
#define ADC_COMPUTED_CLOCK (CPU_FREQ / ((ADC_COMPUTED_PRESCALER + 1) * 2))
|
||||
#define ADC_COMPUTED_STARTUPTIME (((CONFIG_ADC_STARTUP_TIME * ADC_COMPUTED_CLOCK) / 8000000UL) - 1)
|
||||
#define ADC_COMPUTED_SHTIME ((uint32_t)((CONFIG_ADC_SHTIME * (uint64_t)ADC_COMPUTED_CLOCK) / 1000000000UL) - 1)
|
||||
|
||||
/**
|
||||
* Init pins macro for adc.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Define PIO controller for enable ADC function.
|
||||
* \{
|
||||
*/
|
||||
#if CPU_ARM_SAM7X
|
||||
#define ADC_PIO_DISABLE PIOB_PDR
|
||||
#define ADC_PIO_EN_FUNC PIOB_ASR
|
||||
|
||||
#elif CPU_ARM_SAM7S_LARGE
|
||||
#define ADC_PIO_DISABLE PIOA_PDR
|
||||
#define ADC_PIO_EN_FUNC PIOA_BSR
|
||||
|
||||
#else
|
||||
#error No ADC pins name definitions for selected ARM CPU
|
||||
#endif
|
||||
/*\}*/
|
||||
|
||||
/**
|
||||
* Init the ADC pins.
|
||||
* Implement it if necessary.
|
||||
*/
|
||||
#define ADC_INIT_PINS() \
|
||||
do { \
|
||||
} while (0)
|
||||
|
||||
void adc_hw_select_ch(uint8_t ch);
|
||||
uint16_t adc_hw_read(void);
|
||||
void adc_hw_init(void);
|
||||
|
||||
#endif /* DRV_ADC_AT91_H */
|
@ -1,473 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief EMAC driver for AT91SAM7X Family.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
* \author Andrea Righi <arighi@develer.com>
|
||||
*/
|
||||
|
||||
#include "cfg/cfg_eth.h"
|
||||
|
||||
#define LOG_LEVEL ETH_LOG_LEVEL
|
||||
#define LOG_FORMAT ETH_LOG_FORMAT
|
||||
|
||||
#include <cfg/log.h>
|
||||
|
||||
#include <cfg/debug.h>
|
||||
#include <cfg/log.h>
|
||||
#include <cfg/macros.h>
|
||||
#include <cfg/compiler.h>
|
||||
|
||||
#include <io/at91sam7.h>
|
||||
#include <io/arm.h>
|
||||
|
||||
#include <cpu/power.h>
|
||||
#include <cpu/types.h>
|
||||
#include <cpu/irq.h>
|
||||
|
||||
#include <drv/timer.h>
|
||||
#include <drv/eth.h>
|
||||
|
||||
#include <mware/event.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "eth_at91.h"
|
||||
|
||||
#define EMAC_RX_INTS (BV(EMAC_RCOMP) | BV(EMAC_ROVR) | BV(EMAC_RXUBR))
|
||||
#define EMAC_TX_INTS (BV(EMAC_TCOMP) | BV(EMAC_TXUBR) | BV(EMAC_RLEX))
|
||||
|
||||
/* Silent Doxygen bug... */
|
||||
#ifndef __doxygen__
|
||||
/*
|
||||
* NOTE: this buffer should be declared as 'volatile' because it is read by the
|
||||
* hardware. However, this is accessed only via memcpy() that should guarantee
|
||||
* coherency when copying from/to buffers.
|
||||
*/
|
||||
static uint8_t tx_buf[EMAC_TX_BUFFERS * EMAC_TX_BUFSIZ] ALIGNED(8);
|
||||
static volatile BufDescriptor tx_buf_tab[EMAC_TX_DESCRIPTORS] ALIGNED(8);
|
||||
|
||||
/*
|
||||
* NOTE: this buffer should be declared as 'volatile' because it is wrote by
|
||||
* the hardware. However, this is accessed only via memcpy() that should
|
||||
* guarantee coherency when copying from/to buffers.
|
||||
*/
|
||||
static uint8_t rx_buf[EMAC_RX_BUFFERS * EMAC_RX_BUFSIZ] ALIGNED(8);
|
||||
static volatile BufDescriptor rx_buf_tab[EMAC_RX_DESCRIPTORS] ALIGNED(8);
|
||||
#endif
|
||||
|
||||
static int tx_buf_idx;
|
||||
static int tx_buf_offset;
|
||||
static int rx_buf_idx;
|
||||
|
||||
static Event recv_wait, send_wait;
|
||||
|
||||
static DECLARE_ISR(emac_irqHandler)
|
||||
{
|
||||
/* Read interrupt status and disable interrupts. */
|
||||
uint32_t isr = EMAC_ISR;
|
||||
|
||||
/* Receiver interrupt */
|
||||
if ((isr & EMAC_RX_INTS))
|
||||
{
|
||||
if (isr & BV(EMAC_RCOMP))
|
||||
event_do(&recv_wait);
|
||||
EMAC_RSR = EMAC_RX_INTS;
|
||||
}
|
||||
/* Transmitter interrupt */
|
||||
if (isr & EMAC_TX_INTS)
|
||||
{
|
||||
if (isr & BV(EMAC_TCOMP))
|
||||
event_do(&send_wait);
|
||||
EMAC_TSR = EMAC_TX_INTS;
|
||||
}
|
||||
AIC_EOICR = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Read contents of PHY register.
|
||||
*
|
||||
* \param reg PHY register number.
|
||||
*
|
||||
* \return Contents of the specified register.
|
||||
*/
|
||||
static uint16_t phy_hw_read(reg8_t reg)
|
||||
{
|
||||
// PHY read command.
|
||||
EMAC_MAN = EMAC_SOF | EMAC_RW_READ | (NIC_PHY_ADDR << EMAC_PHYA_SHIFT)
|
||||
| ((reg << EMAC_REGA_SHIFT) & EMAC_REGA) | EMAC_CODE;
|
||||
|
||||
// Wait until PHY logic completed.
|
||||
while (!(EMAC_NSR & BV(EMAC_IDLE)))
|
||||
cpu_relax();
|
||||
|
||||
// Get data from PHY maintenance register.
|
||||
return (uint16_t)(EMAC_MAN & EMAC_DATA);
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Write value to PHY register.
|
||||
*
|
||||
* \param reg PHY register number.
|
||||
* \param val Value to write.
|
||||
*/
|
||||
static void phy_hw_write(reg8_t reg, uint16_t val)
|
||||
{
|
||||
// PHY write command.
|
||||
EMAC_MAN = EMAC_SOF | EMAC_RW_WRITE | (NIC_PHY_ADDR << EMAC_PHYA_SHIFT)
|
||||
| ((reg << EMAC_REGA_SHIFT) & EMAC_REGA) | EMAC_CODE | val;
|
||||
|
||||
// Wait until PHY logic completed.
|
||||
while (!(EMAC_NSR & BV(EMAC_IDLE)))
|
||||
cpu_relax();
|
||||
}
|
||||
|
||||
static int emac_reset(void)
|
||||
{
|
||||
uint16_t phy_cr;
|
||||
|
||||
// Enable devices
|
||||
PMC_PCER = BV(PIOA_ID);
|
||||
PMC_PCER = BV(PIOB_ID);
|
||||
PMC_PCER = BV(EMAC_ID);
|
||||
|
||||
// Disable RMII and TESTMODE by disabling pull-ups.
|
||||
PIOB_PUDR = BV(PHY_COL_RMII_BIT) | BV(PHY_RXDV_TESTMODE_BIT);
|
||||
|
||||
// Disable PHY power down.
|
||||
PIOB_PER = BV(PHY_PWRDN_BIT);
|
||||
PIOB_OER = BV(PHY_PWRDN_BIT);
|
||||
PIOB_CODR = BV(PHY_PWRDN_BIT);
|
||||
|
||||
// Toggle external hardware reset pin.
|
||||
RSTC_MR = RSTC_KEY | (1 << RSTC_ERSTL_SHIFT) | BV(RSTC_URSTEN);
|
||||
RSTC_CR = RSTC_KEY | BV(RSTC_EXTRST);
|
||||
|
||||
while ((RSTC_SR & BV(RSTC_NRSTL)) == 0)
|
||||
cpu_relax();
|
||||
|
||||
// Configure MII port.
|
||||
PIOB_ASR = PHY_MII_PINS;
|
||||
PIOB_BSR = 0;
|
||||
PIOB_PDR = PHY_MII_PINS;
|
||||
|
||||
// Enable receive and transmit clocks.
|
||||
EMAC_USRIO = BV(EMAC_CLKEN);
|
||||
|
||||
// Enable management port.
|
||||
EMAC_NCR |= BV(EMAC_MPE);
|
||||
EMAC_NCFGR |= EMAC_CLK_HCLK_32;
|
||||
|
||||
// Set local MAC address.
|
||||
EMAC_SA1L = (mac_addr[3] << 24) | (mac_addr[2] << 16) |
|
||||
(mac_addr[1] << 8) | mac_addr[0];
|
||||
EMAC_SA1H = (mac_addr[5] << 8) | mac_addr[4];
|
||||
|
||||
// Wait for PHY ready
|
||||
timer_delay(255);
|
||||
|
||||
// Clear MII isolate.
|
||||
phy_hw_read(NIC_PHY_BMCR);
|
||||
phy_cr = phy_hw_read(NIC_PHY_BMCR);
|
||||
|
||||
phy_cr &= ~NIC_PHY_BMCR_ISOLATE;
|
||||
phy_hw_write(NIC_PHY_BMCR, phy_cr);
|
||||
|
||||
phy_cr = phy_hw_read(NIC_PHY_BMCR);
|
||||
|
||||
LOG_INFO("%s: PHY ID %#04x %#04x\n",
|
||||
__func__,
|
||||
phy_hw_read(NIC_PHY_ID1), phy_hw_read(NIC_PHY_ID2));
|
||||
|
||||
// Wait for auto negotiation completed.
|
||||
phy_hw_read(NIC_PHY_BMSR);
|
||||
for (;;)
|
||||
{
|
||||
if (phy_hw_read(NIC_PHY_BMSR) & NIC_PHY_BMSR_ANCOMPL)
|
||||
break;
|
||||
cpu_relax();
|
||||
}
|
||||
|
||||
// Disable management port.
|
||||
EMAC_NCR &= ~BV(EMAC_MPE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int emac_start(void)
|
||||
{
|
||||
uint32_t addr;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < EMAC_RX_DESCRIPTORS; i++)
|
||||
{
|
||||
addr = (uint32_t)(rx_buf + (i * EMAC_RX_BUFSIZ));
|
||||
rx_buf_tab[i].addr = addr & BUF_ADDRMASK;
|
||||
}
|
||||
rx_buf_tab[EMAC_RX_DESCRIPTORS - 1].addr |= RXBUF_WRAP;
|
||||
|
||||
for (i = 0; i < EMAC_TX_DESCRIPTORS; i++)
|
||||
{
|
||||
addr = (uint32_t)(tx_buf + (i * EMAC_TX_BUFSIZ));
|
||||
tx_buf_tab[i].addr = addr & BUF_ADDRMASK;
|
||||
tx_buf_tab[i].stat = TXS_USED;
|
||||
}
|
||||
tx_buf_tab[EMAC_TX_DESCRIPTORS - 1].stat = TXS_USED | TXS_WRAP;
|
||||
|
||||
/* Tell the EMAC where to find the descriptors. */
|
||||
EMAC_RBQP = (uint32_t)rx_buf_tab;
|
||||
EMAC_TBQP = (uint32_t)tx_buf_tab;
|
||||
|
||||
/* Clear receiver status. */
|
||||
EMAC_RSR = BV(EMAC_OVR) | BV(EMAC_REC) | BV(EMAC_BNA);
|
||||
|
||||
/* Copy all frames and discard FCS. */
|
||||
EMAC_NCFGR |= BV(EMAC_CAF) | BV(EMAC_DRFCS);
|
||||
|
||||
/* Enable receiver, transmitter and statistics. */
|
||||
EMAC_NCR |= BV(EMAC_TE) | BV(EMAC_RE) | BV(EMAC_WESTAT);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ssize_t eth_putFrame(const uint8_t *buf, size_t len)
|
||||
{
|
||||
size_t wr_len;
|
||||
|
||||
if (UNLIKELY(!len))
|
||||
return -1;
|
||||
ASSERT(len <= sizeof(tx_buf));
|
||||
|
||||
/* Check if the transmit buffer is available */
|
||||
while (!(tx_buf_tab[tx_buf_idx].stat & TXS_USED))
|
||||
event_wait(&send_wait);
|
||||
|
||||
/* Copy the data into the buffer and prepare descriptor */
|
||||
wr_len = MIN(len, (size_t)EMAC_TX_BUFSIZ - tx_buf_offset);
|
||||
memcpy((uint8_t *)tx_buf_tab[tx_buf_idx].addr + tx_buf_offset,
|
||||
buf, wr_len);
|
||||
tx_buf_offset += wr_len;
|
||||
|
||||
return wr_len;
|
||||
}
|
||||
|
||||
void eth_sendFrame(void)
|
||||
{
|
||||
tx_buf_tab[tx_buf_idx].stat = (tx_buf_offset & TXS_LENGTH_FRAME) |
|
||||
TXS_LAST_BUFF |
|
||||
((tx_buf_idx == EMAC_TX_DESCRIPTORS - 1) ? TXS_WRAP : 0);
|
||||
EMAC_NCR |= BV(EMAC_TSTART);
|
||||
|
||||
tx_buf_offset = 0;
|
||||
if (++tx_buf_idx >= EMAC_TX_DESCRIPTORS)
|
||||
tx_buf_idx = 0;
|
||||
}
|
||||
|
||||
ssize_t eth_send(const uint8_t *buf, size_t len)
|
||||
{
|
||||
if (UNLIKELY(!len))
|
||||
return -1;
|
||||
|
||||
len = eth_putFrame(buf, len);
|
||||
eth_sendFrame();
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static void eth_buf_realign(int idx)
|
||||
{
|
||||
/* Empty buffer found. Realign. */
|
||||
do {
|
||||
rx_buf_tab[rx_buf_idx].addr &= ~RXBUF_OWNERSHIP;
|
||||
if (++rx_buf_idx >= EMAC_RX_BUFFERS)
|
||||
rx_buf_idx = 0;
|
||||
} while (idx != rx_buf_idx);
|
||||
}
|
||||
|
||||
static size_t __eth_getFrameLen(void)
|
||||
{
|
||||
int idx, n = EMAC_RX_BUFFERS;
|
||||
|
||||
skip:
|
||||
/* Skip empty buffers */
|
||||
while ((n > 0) && !(rx_buf_tab[rx_buf_idx].addr & RXBUF_OWNERSHIP))
|
||||
{
|
||||
if (++rx_buf_idx >= EMAC_RX_BUFFERS)
|
||||
rx_buf_idx = 0;
|
||||
n--;
|
||||
}
|
||||
if (UNLIKELY(!n))
|
||||
{
|
||||
LOG_INFO("no frame found\n");
|
||||
return 0;
|
||||
}
|
||||
/* Search the start of frame and cleanup fragments */
|
||||
while ((n > 0) && (rx_buf_tab[rx_buf_idx].addr & RXBUF_OWNERSHIP) &&
|
||||
!(rx_buf_tab[rx_buf_idx].stat & RXS_SOF))
|
||||
{
|
||||
rx_buf_tab[rx_buf_idx].addr &= ~RXBUF_OWNERSHIP;
|
||||
if (++rx_buf_idx >= EMAC_RX_BUFFERS)
|
||||
rx_buf_idx = 0;
|
||||
n--;
|
||||
}
|
||||
if (UNLIKELY(!n))
|
||||
{
|
||||
LOG_INFO("no SOF found\n");
|
||||
return 0;
|
||||
}
|
||||
/* Search end of frame to evaluate the total frame size */
|
||||
idx = rx_buf_idx;
|
||||
restart:
|
||||
while (n > 0)
|
||||
{
|
||||
if (UNLIKELY(!(rx_buf_tab[idx].addr & RXBUF_OWNERSHIP)))
|
||||
{
|
||||
/* Empty buffer found. Realign. */
|
||||
eth_buf_realign(idx);
|
||||
goto skip;
|
||||
}
|
||||
if (rx_buf_tab[idx].stat & RXS_EOF)
|
||||
return rx_buf_tab[idx].stat & RXS_LENGTH_FRAME;
|
||||
if (UNLIKELY((idx != rx_buf_idx) &&
|
||||
(rx_buf_tab[idx].stat & RXS_SOF)))
|
||||
{
|
||||
/* Another start of frame found. Realign. */
|
||||
eth_buf_realign(idx);
|
||||
goto restart;
|
||||
}
|
||||
if (++idx >= EMAC_RX_BUFFERS)
|
||||
idx = 0;
|
||||
n--;
|
||||
}
|
||||
LOG_INFO("no EOF found\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t eth_getFrameLen(void)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
/* Check if there is at least one available frame in the buffer */
|
||||
while (1)
|
||||
{
|
||||
len = __eth_getFrameLen();
|
||||
if (LIKELY(len))
|
||||
break;
|
||||
/* Wait for RX interrupt */
|
||||
event_wait(&recv_wait);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
ssize_t eth_getFrame(uint8_t *buf, size_t len)
|
||||
{
|
||||
uint8_t *addr;
|
||||
size_t rd_len = 0;
|
||||
|
||||
if (UNLIKELY(!len))
|
||||
return -1;
|
||||
ASSERT(len <= sizeof(rx_buf));
|
||||
|
||||
/* Copy data from the RX buffer */
|
||||
addr = (uint8_t *)(rx_buf_tab[rx_buf_idx].addr & BUF_ADDRMASK);
|
||||
if (addr + len > &rx_buf[countof(rx_buf)])
|
||||
{
|
||||
size_t count = &rx_buf[countof(rx_buf)] - addr;
|
||||
|
||||
memcpy(buf, addr, count);
|
||||
memcpy(buf + count, rx_buf, len - count);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(buf, addr, len);
|
||||
}
|
||||
/* Update descriptors */
|
||||
while (rd_len < len)
|
||||
{
|
||||
if (len - rd_len >= EMAC_RX_BUFSIZ)
|
||||
rd_len += EMAC_RX_BUFSIZ;
|
||||
else
|
||||
rd_len += len - rd_len;
|
||||
if (UNLIKELY(!(rx_buf_tab[rx_buf_idx].addr & RXBUF_OWNERSHIP)))
|
||||
{
|
||||
LOG_INFO("bad frame found\n");
|
||||
return 0;
|
||||
}
|
||||
rx_buf_tab[rx_buf_idx].addr &= ~RXBUF_OWNERSHIP;
|
||||
if (++rx_buf_idx >= EMAC_RX_DESCRIPTORS)
|
||||
rx_buf_idx = 0;
|
||||
}
|
||||
|
||||
return rd_len;
|
||||
}
|
||||
|
||||
ssize_t eth_recv(uint8_t *buf, size_t len)
|
||||
{
|
||||
if (UNLIKELY(!len))
|
||||
return -1;
|
||||
len = MIN(len, eth_getFrameLen());
|
||||
return len ? eth_getFrame(buf, len) : 0;
|
||||
}
|
||||
|
||||
int eth_init()
|
||||
{
|
||||
cpu_flags_t flags;
|
||||
|
||||
emac_reset();
|
||||
emac_start();
|
||||
|
||||
event_initGeneric(&recv_wait);
|
||||
event_initGeneric(&send_wait);
|
||||
|
||||
// Register interrupt vector
|
||||
IRQ_SAVE_DISABLE(flags);
|
||||
|
||||
/* Disable all emac interrupts */
|
||||
EMAC_IDR = 0xFFFFFFFF;
|
||||
|
||||
/* Set the vector. */
|
||||
AIC_SVR(EMAC_ID) = emac_irqHandler;
|
||||
/* Initialize to edge triggered with defined priority. */
|
||||
AIC_SMR(EMAC_ID) = AIC_SRCTYPE_INT_EDGE_TRIGGERED;
|
||||
/* Clear pending interrupt */
|
||||
AIC_ICCR = BV(EMAC_ID);
|
||||
/* Enable the system IRQ */
|
||||
AIC_IECR = BV(EMAC_ID);
|
||||
|
||||
/* Enable interrupts */
|
||||
EMAC_IER = EMAC_RX_INTS | EMAC_TX_INTS;
|
||||
|
||||
IRQ_RESTORE(flags);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,165 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2009 Develer S.r.l. (http://www.develer.com/)
|
||||
* All Rights Reserved.
|
||||
* -->
|
||||
*
|
||||
* \brief EMAC driver for AT91SAM7X Family, interface.
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
* \author Andrea Righi <arighi@develer.com>
|
||||
*/
|
||||
|
||||
#ifndef ETH_AT91_H
|
||||
#define ETH_AT91_H
|
||||
|
||||
// Settings and definition for DAVICOM 9161A
|
||||
// \{
|
||||
#define NIC_PHY_ADDR 31
|
||||
|
||||
//Registry definition
|
||||
#define NIC_PHY_BMCR 0x00 // Basic mode control register.
|
||||
#define NIC_PHY_BMCR_COLTEST 0x0080 // Collision test.
|
||||
#define NIC_PHY_BMCR_FDUPLEX 0x0100 // Full duplex mode.
|
||||
#define NIC_PHY_BMCR_ANEGSTART 0x0200 // Restart auto negotiation.
|
||||
#define NIC_PHY_BMCR_ISOLATE 0x0400 // Isolate from MII.
|
||||
#define NIC_PHY_BMCR_PWRDN 0x0800 // Power-down.
|
||||
#define NIC_PHY_BMCR_ANEGENA 0x1000 // Enable auto negotiation.
|
||||
#define NIC_PHY_BMCR_100MBPS 0x2000 // Select 100 Mbps.
|
||||
#define NIC_PHY_BMCR_LOOPBACK 0x4000 // Enable loopback mode.
|
||||
#define NIC_PHY_BMCR_RESET 0x8000 // Software reset.
|
||||
|
||||
#define NIC_PHY_BMSR 0x01 // Basic mode status register.
|
||||
#define NIC_PHY_BMSR_ANCOMPL 0x0020 // Auto negotiation complete.
|
||||
#define NIC_PHY_BMSR_ANEGCAPABLE 0x0008 // Able to do auto-negotiation
|
||||
#define NIC_PHY_BMSR_LINKSTAT 0x0004 // Link status.
|
||||
|
||||
#define NIC_PHY_ID1 0x02 // PHY identifier register 1.
|
||||
#define NIC_PHY_ID2 0x03 // PHY identifier register 2.
|
||||
#define NIC_PHY_ANAR 0x04 // Auto negotiation advertisement register.
|
||||
#define NIC_PHY_ANLPAR 0x05 // Auto negotiation link partner availability register.
|
||||
#define NIC_PHY_ANER 0x06 // Auto negotiation expansion register.
|
||||
|
||||
// Pin definition for DAVICOM 9161A
|
||||
// See schematic for at91sam7x-ek evalution board
|
||||
#define PHY_TXCLK_ISOLATE_BIT 0
|
||||
#define PHY_REFCLK_XT2_BIT 0
|
||||
#define PHY_TXEN_BIT 1
|
||||
#define PHY_TXD0_BIT 2
|
||||
#define PHY_TXD1_BIT 3
|
||||
#define PHY_CRS_AD4_BIT 4
|
||||
#define PHY_RXD0_AD0_BIT 5
|
||||
#define PHY_RXD1_AD1_BIT 6
|
||||
#define PHY_RXER_RXD4_RPTR_BIT 7
|
||||
#define PHY_MDC_BIT 8
|
||||
#define PHY_MDIO_BIT 9
|
||||
#define PHY_TXD2_BIT 10
|
||||
#define PHY_TXD3_BIT 11
|
||||
#define PHY_TXER_TXD4_BIT 12
|
||||
#define PHY_RXD2_AD2_BIT 13
|
||||
#define PHY_RXD3_AD3_BIT 14
|
||||
#define PHY_RXDV_TESTMODE_BIT 15
|
||||
#define PHY_COL_RMII_BIT 16
|
||||
#define PHY_RXCLK_10BTSER_BIT 17
|
||||
#define PHY_PWRDN_BIT 18
|
||||
#define PHY_MDINTR_BIT 26
|
||||
|
||||
#define PHY_MII_PINS BV(PHY_REFCLK_XT2_BIT) \
|
||||
| BV(PHY_TXEN_BIT) \
|
||||
| BV(PHY_TXD0_BIT) \
|
||||
| BV(PHY_TXD1_BIT) \
|
||||
| BV(PHY_CRS_AD4_BIT) \
|
||||
| BV(PHY_RXD0_AD0_BIT) \
|
||||
| BV(PHY_RXD1_AD1_BIT) \
|
||||
| BV(PHY_RXER_RXD4_RPTR_BIT) \
|
||||
| BV(PHY_MDC_BIT) \
|
||||
| BV(PHY_MDIO_BIT) \
|
||||
| BV(PHY_TXD2_BIT) \
|
||||
| BV(PHY_TXD3_BIT) \
|
||||
| BV(PHY_TXER_TXD4_BIT) \
|
||||
| BV(PHY_RXD2_AD2_BIT) \
|
||||
| BV(PHY_RXD3_AD3_BIT) \
|
||||
| BV(PHY_RXDV_TESTMODE_BIT) \
|
||||
| BV(PHY_COL_RMII_BIT) \
|
||||
| BV(PHY_RXCLK_10BTSER_BIT)
|
||||
// \}
|
||||
|
||||
#define EMAC_TX_BUFSIZ 1518 //!!! Don't change this
|
||||
#define EMAC_TX_BUFFERS 1 //!!! Don't change this
|
||||
#define EMAC_TX_DESCRIPTORS EMAC_TX_BUFFERS
|
||||
|
||||
#define EMAC_RX_BUFFERS 32 //!!! Don't change this
|
||||
#define EMAC_RX_BUFSIZ 128 //!!! Don't change this
|
||||
#define EMAC_RX_DESCRIPTORS EMAC_RX_BUFFERS
|
||||
|
||||
// Flag to manage local tx buffer
|
||||
#define TXS_USED 0x80000000 //Used buffer.
|
||||
#define TXS_WRAP 0x40000000 //Last descriptor.
|
||||
#define TXS_ERROR 0x20000000 //Retry limit exceeded.
|
||||
#define TXS_UNDERRUN 0x10000000 //Transmit underrun.
|
||||
#define TXS_NO_BUFFER 0x08000000 //Buffer exhausted.
|
||||
#define TXS_NO_CRC 0x00010000 //CRC not appended.
|
||||
#define TXS_LAST_BUFF 0x00008000 //Last buffer of frame.
|
||||
#define TXS_LENGTH_FRAME 0x000007FF // Length of frame including FCS.
|
||||
|
||||
// Flag to manage local rx buffer
|
||||
#define RXBUF_OWNERSHIP 0x00000001
|
||||
#define RXBUF_WRAP 0x00000002
|
||||
|
||||
#define BUF_ADDRMASK 0xFFFFFFFC
|
||||
|
||||
#define RXS_BROADCAST_ADDR 0x80000000 // Broadcast address detected.
|
||||
#define RXS_MULTICAST_HASH 0x40000000 // Multicast hash match.
|
||||
#define RXS_UNICAST_HASH 0x20000000 // Unicast hash match.
|
||||
#define RXS_EXTERNAL_ADDR 0x10000000 // External address match.
|
||||
#define RXS_SA1_ADDR 0x04000000 // Specific address register 1 match.
|
||||
#define RXS_SA2_ADDR 0x02000000 // Specific address register 2 match.
|
||||
#define RXS_SA3_ADDR 0x01000000 // Specific address register 3 match.
|
||||
#define RXS_SA4_ADDR 0x00800000 // Specific address register 4 match.
|
||||
#define RXS_TYPE_ID 0x00400000 // Type ID match.
|
||||
#define RXS_VLAN_TAG 0x00200000 // VLAN tag detected.
|
||||
#define RXS_PRIORITY_TAG 0x00100000 // Priority tag detected.
|
||||
#define RXS_VLAN_PRIORITY 0x000E0000 // VLAN priority.
|
||||
#define RXS_CFI_IND 0x00010000 // Concatenation format indicator.
|
||||
#define RXS_EOF 0x00008000 // End of frame.
|
||||
#define RXS_SOF 0x00004000 // Start of frame.
|
||||
#define RXS_RBF_OFFSET 0x00003000 // Receive buffer offset mask.
|
||||
#define RXS_LENGTH_FRAME 0x000007FF // Length of frame including FCS.
|
||||
|
||||
#define EMAC_RSR_BITS (BV(EMAC_BNA) | BV(EMAC_REC) | BV(EMAC_OVR))
|
||||
#define EMAC_TSR_BITS (BV(EMAC_UBR) | BV(EMAC_COL) | BV(EMAC_RLES) | \
|
||||
BV(EMAC_BEX) | BV(EMAC_COMP) | BV(EMAC_UND))
|
||||
|
||||
typedef struct BufDescriptor
|
||||
{
|
||||
volatile uint32_t addr;
|
||||
volatile uint32_t stat;
|
||||
} BufDescriptor;
|
||||
|
||||
#endif /* ETH_AT91_H */
|
@ -1,48 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2007 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Low-level flash module for ARM (interface).
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cpu/detect.h>
|
||||
|
||||
#if CPU_ARM_AT91
|
||||
#include "flash_at91.h"
|
||||
#elif CPU_ARM_LPC2
|
||||
#include "flash_lpc2.h"
|
||||
/*#elif Add other ARM families here */
|
||||
#else
|
||||
#error Unknown CPU
|
||||
#endif
|
@ -1,241 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2009 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
* \brief At91sam7 Internal flash read/write driver.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "flash_at91.h"
|
||||
|
||||
#include "cfg/cfg_emb_flash.h"
|
||||
#include <cfg/macros.h>
|
||||
|
||||
// Define log settings for cfg/log.h
|
||||
#define LOG_LEVEL CONFIG_FLASH_EMB_LOG_LEVEL
|
||||
#define LOG_FORMAT CONFIG_FLASH_EMB_LOG_FORMAT
|
||||
#include <cfg/log.h>
|
||||
|
||||
#include <cpu/irq.h>
|
||||
#include <cpu/attr.h>
|
||||
#include <cpu/power.h>
|
||||
|
||||
#include <io/kfile.h>
|
||||
#include <io/kblock.h>
|
||||
#include <io/arm.h>
|
||||
|
||||
#include <drv/timer.h>
|
||||
#include <drv/flash.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
struct FlashHardware
|
||||
{
|
||||
uint8_t status;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Really send the flash write command.
|
||||
*
|
||||
* \note This function has to be placed in RAM because
|
||||
* executing code from flash while a writing process
|
||||
* is in progress is forbidden.
|
||||
*/
|
||||
RAM_FUNC NOINLINE static void write_page(uint32_t page)
|
||||
{
|
||||
// Send the 'write page' command
|
||||
MC_FCR = MC_KEY | MC_FCMD_WP | (MC_PAGEN_MASK & (page << 8));
|
||||
|
||||
// Wait for the end of command
|
||||
while(!(MC_FSR & BV(MC_FRDY)))
|
||||
{
|
||||
//NOP;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send write command.
|
||||
*
|
||||
* After WR command cpu write bufferd page into flash memory.
|
||||
*
|
||||
*/
|
||||
INLINE void flash_sendWRcmd(uint32_t page)
|
||||
{
|
||||
cpu_flags_t flags;
|
||||
|
||||
LOG_INFO("Writing page %ld...\n", page);
|
||||
|
||||
IRQ_SAVE_DISABLE(flags);
|
||||
write_page(page);
|
||||
|
||||
IRQ_RESTORE(flags);
|
||||
LOG_INFO("Done\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if no error are occurred after flash memory
|
||||
* read or write operation, otherwise return error code.
|
||||
*/
|
||||
static bool flash_getStatus(struct KBlock *blk)
|
||||
{
|
||||
Flash *fls = FLASH_CAST(blk);
|
||||
/*
|
||||
* This bit is set to one if an invalid command and/or a bad keywords was/were
|
||||
* written in the Flash Command Register.
|
||||
*/
|
||||
if(MC_FSR & BV(MC_PROGE))
|
||||
{
|
||||
fls->hw->status |= FLASH_WR_ERR;
|
||||
LOG_ERR("flash not erased..\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* This bit is set to one if we programming of at least one locked lock
|
||||
* region.
|
||||
*/
|
||||
if(MC_FSR & BV(MC_LOCKE))
|
||||
{
|
||||
fls->hw->status |= FLASH_WR_PROTECT;
|
||||
LOG_ERR("wr protect..\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static size_t at91_flash_readDirect(struct KBlock *blk, block_idx_t idx, void *buf, size_t offset, size_t size)
|
||||
{
|
||||
memcpy(buf, (void *)(idx * blk->blk_size + FLASH_BASE + offset), size);
|
||||
return size;
|
||||
}
|
||||
|
||||
static size_t at91_flash_writeDirect(struct KBlock *blk, block_idx_t idx, const void *_buf, size_t offset, size_t size)
|
||||
{
|
||||
ASSERT(offset == 0);
|
||||
ASSERT(size == blk->blk_size);
|
||||
|
||||
uint32_t *addr = (uint32_t *)(idx * blk->blk_size + FLASH_BASE);
|
||||
const uint8_t *buf = (const uint8_t *)_buf;
|
||||
|
||||
while (size)
|
||||
{
|
||||
uint32_t data = (*(buf + 3) << 24) |
|
||||
(*(buf + 2) << 16) |
|
||||
(*(buf + 1) << 8) |
|
||||
*buf;
|
||||
*addr = data;
|
||||
|
||||
size -= 4;
|
||||
buf += 4;
|
||||
addr++;
|
||||
}
|
||||
|
||||
flash_sendWRcmd(idx);
|
||||
|
||||
if (!flash_getStatus(blk))
|
||||
return 0;
|
||||
|
||||
return blk->blk_size;
|
||||
}
|
||||
|
||||
|
||||
static int at91_flash_error(struct KBlock *blk)
|
||||
{
|
||||
Flash *fls = FLASH_CAST(blk);
|
||||
return fls->hw->status;
|
||||
}
|
||||
|
||||
static void at91_flash_clearerror(struct KBlock *blk)
|
||||
{
|
||||
Flash *fls = FLASH_CAST(blk);
|
||||
fls->hw->status = 0;
|
||||
}
|
||||
|
||||
static const KBlockVTable flash_at91_buffered_vt =
|
||||
{
|
||||
.readDirect = at91_flash_readDirect,
|
||||
.writeDirect = at91_flash_writeDirect,
|
||||
|
||||
.readBuf = kblock_swReadBuf,
|
||||
.writeBuf = kblock_swWriteBuf,
|
||||
.load = kblock_swLoad,
|
||||
.store = kblock_swStore,
|
||||
|
||||
.error = at91_flash_error,
|
||||
.clearerr = at91_flash_clearerror,
|
||||
};
|
||||
|
||||
static const KBlockVTable flash_at91_unbuffered_vt =
|
||||
{
|
||||
.readDirect = at91_flash_readDirect,
|
||||
.writeDirect = at91_flash_writeDirect,
|
||||
|
||||
.error = at91_flash_error,
|
||||
.clearerr = at91_flash_clearerror,
|
||||
};
|
||||
|
||||
static struct FlashHardware flash_at91_hw;
|
||||
static uint8_t flash_buf[FLASH_PAGE_SIZE_BYTES];
|
||||
|
||||
static void common_init(Flash *fls)
|
||||
{
|
||||
memset(fls, 0, sizeof(*fls));
|
||||
DB(fls->blk.priv.type = KBT_FLASH);
|
||||
|
||||
fls->hw = &flash_at91_hw;
|
||||
|
||||
fls->blk.blk_size = FLASH_PAGE_SIZE_BYTES;
|
||||
fls->blk.blk_cnt = FLASH_MEM_SIZE / FLASH_PAGE_SIZE_BYTES;
|
||||
}
|
||||
|
||||
void flash_hw_init(Flash *fls, UNUSED_ARG(int, flags))
|
||||
{
|
||||
common_init(fls);
|
||||
fls->blk.priv.vt = &flash_at91_buffered_vt;
|
||||
fls->blk.priv.flags |= KB_BUFFERED | KB_PARTIAL_WRITE;
|
||||
fls->blk.priv.buf = flash_buf;
|
||||
|
||||
/* Load the first block in the cache */
|
||||
memcpy(fls->blk.priv.buf, (void *)(FLASH_BASE), fls->blk.blk_size);
|
||||
}
|
||||
|
||||
void flash_hw_initUnbuffered(Flash *fls, UNUSED_ARG(int, flags))
|
||||
{
|
||||
common_init(fls);
|
||||
fls->blk.priv.vt = &flash_at91_unbuffered_vt;
|
||||
}
|
||||
|
@ -1,52 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2009 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
* \brief At91sam7 Internal flash read/write driver.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FLASH_AT91_H
|
||||
#define FLASH_AT91_H
|
||||
|
||||
#include "cfg/cfg_emb_flash.h"
|
||||
|
||||
#if !CONFIG_FLASH_DISABLE_OLD_API
|
||||
|
||||
/* For backwards compatibility */
|
||||
#define FlashAt91 Flash
|
||||
#define flash_at91_init(fls) flash_init(fls);
|
||||
#endif /* !CONFIG_FLASH_DISABLE_OLD_API */
|
||||
|
||||
#endif /* DRV_FLASH_ARM_H */
|
@ -1,365 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \author Francesco Sacchi <batt@develer.com>
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
* \brief NPX lpc23xx embedded flash read/write driver.
|
||||
*
|
||||
* notest:arm
|
||||
*/
|
||||
|
||||
#include "flash_lpc2.h"
|
||||
#include "cfg/cfg_emb_flash.h"
|
||||
|
||||
// Define log settings for cfg/log.h
|
||||
#define LOG_LEVEL CONFIG_FLASH_EMB_LOG_LEVEL
|
||||
#define LOG_FORMAT CONFIG_FLASH_EMB_LOG_FORMAT
|
||||
#include <cfg/log.h>
|
||||
#include <cfg/macros.h>
|
||||
|
||||
#include <cpu/irq.h>
|
||||
#include <cpu/attr.h>
|
||||
#include <cpu/power.h>
|
||||
#include <cpu/types.h>
|
||||
|
||||
#include <io/kblock.h>
|
||||
#include <io/arm.h>
|
||||
|
||||
#include <drv/timer.h>
|
||||
#include <drv/flash.h>
|
||||
|
||||
#include <struct/bitarray.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* Embedded flash programming defines. */
|
||||
#define IAP_ADDRESS 0x7ffffff1
|
||||
|
||||
typedef enum IapCommands
|
||||
{
|
||||
PREPARE_SECTOR_FOR_WRITE = 50,
|
||||
COPY_RAM_TO_FLASH = 51,
|
||||
ERASE_SECTOR = 52,
|
||||
BLANK_CHECK_SECTOR = 53,
|
||||
READ_PART_ID = 54,
|
||||
READ_BOOT_VER = 55,
|
||||
COMPARE = 56,
|
||||
REINVOKE_ISP = 57,
|
||||
} IapCommands;
|
||||
|
||||
#if CPU_ARM_LPC2378
|
||||
#define FLASH_MEM_SIZE (504 * 1024L)
|
||||
#define FLASH_PAGE_SIZE_BYTES 4096
|
||||
#define FLASH_REAL_PAGE_CNT 28
|
||||
#else
|
||||
#error Unknown CPU
|
||||
#endif
|
||||
|
||||
#define CMD_SUCCESS 0
|
||||
|
||||
struct FlashHardware
|
||||
{
|
||||
uint8_t status;
|
||||
int flags;
|
||||
};
|
||||
|
||||
#define FLASH_PAGE_CNT FLASH_MEM_SIZE / FLASH_PAGE_SIZE_BYTES
|
||||
|
||||
BITARRAY_ALLOC(page_dirty, FLASH_PAGE_CNT);
|
||||
static BitArray lpc2_bitx;
|
||||
|
||||
uint8_t erase_group[] = {
|
||||
|
||||
4096 / FLASH_PAGE_SIZE_BYTES, 4096 / FLASH_PAGE_SIZE_BYTES,
|
||||
4096 / FLASH_PAGE_SIZE_BYTES, 4096 / FLASH_PAGE_SIZE_BYTES,
|
||||
|
||||
4096 / FLASH_PAGE_SIZE_BYTES, 4096 / FLASH_PAGE_SIZE_BYTES,
|
||||
4096 / FLASH_PAGE_SIZE_BYTES, 4096 / FLASH_PAGE_SIZE_BYTES,
|
||||
|
||||
32768 / FLASH_PAGE_SIZE_BYTES, 32768 / FLASH_PAGE_SIZE_BYTES,
|
||||
32768 / FLASH_PAGE_SIZE_BYTES, 32768 / FLASH_PAGE_SIZE_BYTES,
|
||||
|
||||
32768 / FLASH_PAGE_SIZE_BYTES, 32768 / FLASH_PAGE_SIZE_BYTES,
|
||||
32768 / FLASH_PAGE_SIZE_BYTES, 32768 / FLASH_PAGE_SIZE_BYTES,
|
||||
|
||||
32768 / FLASH_PAGE_SIZE_BYTES, 32768 / FLASH_PAGE_SIZE_BYTES,
|
||||
32768 / FLASH_PAGE_SIZE_BYTES, 32768 / FLASH_PAGE_SIZE_BYTES,
|
||||
|
||||
32768 / FLASH_PAGE_SIZE_BYTES, 32768 / FLASH_PAGE_SIZE_BYTES,
|
||||
4096 / FLASH_PAGE_SIZE_BYTES, 4096 / FLASH_PAGE_SIZE_BYTES,
|
||||
|
||||
4096 / FLASH_PAGE_SIZE_BYTES, 4096 / FLASH_PAGE_SIZE_BYTES,
|
||||
4096 / FLASH_PAGE_SIZE_BYTES, 4096 / FLASH_PAGE_SIZE_BYTES,
|
||||
};
|
||||
|
||||
typedef struct IapCmd
|
||||
{
|
||||
uint32_t cmd;
|
||||
uint32_t param[4];
|
||||
} IapCmd;
|
||||
|
||||
typedef struct IapRes
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t res[2];
|
||||
} IapRes;
|
||||
|
||||
typedef void (*iap_callback_t)(IapCmd *, IapRes *);
|
||||
|
||||
iap_callback_t iap = (iap_callback_t)IAP_ADDRESS;
|
||||
|
||||
static size_t sector_size(uint32_t page)
|
||||
{
|
||||
if (page < 8)
|
||||
return 4096;
|
||||
else if (page < 22)
|
||||
return 32768;
|
||||
else if (page < 28)
|
||||
return 4096;
|
||||
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t sector_addr(uint32_t page)
|
||||
{
|
||||
if (page < 8)
|
||||
return page * 4096;
|
||||
else if (page < 22)
|
||||
return (page - 8) * 32768 + 4096 * 8;
|
||||
else if (page < 28)
|
||||
return (page - 22) * 4096 + 32768 * 14 + 4096 * 8;
|
||||
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static uint32_t addr_to_sector(size_t addr)
|
||||
{
|
||||
if (addr < 4096 * 8)
|
||||
return addr / 4096;
|
||||
else if (addr < 4096 * 8 + 32768L * 14)
|
||||
return ((addr - 4096 * 8) / 32768) + 8;
|
||||
else if (addr < 4096 * 8 + 32768L * 14 + 4096 * 6)
|
||||
return ((addr - 4096 * 8 - 32768L * 14) / 4096) + 22;
|
||||
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t lpc2_flash_readDirect(struct KBlock *blk, block_idx_t idx, void *buf, size_t offset, size_t size)
|
||||
{
|
||||
memcpy(buf, (void *)(idx * blk->blk_size + offset), size);
|
||||
return size;
|
||||
}
|
||||
|
||||
static size_t lpc2_flash_writeDirect(struct KBlock *blk, block_idx_t idx, const void *_buf, size_t offset, size_t size)
|
||||
{
|
||||
ASSERT(offset == 0);
|
||||
ASSERT(FLASH_PAGE_SIZE_BYTES == size);
|
||||
|
||||
Flash *fls = FLASH_CAST(blk);
|
||||
if (!(fls->hw->flags & FLASH_WRITE_ONCE))
|
||||
ASSERT(sector_size(idx) <= FLASH_PAGE_SIZE_BYTES);
|
||||
|
||||
const uint8_t *buf = (const uint8_t *)_buf;
|
||||
cpu_flags_t flags;
|
||||
|
||||
//Compute page address of current page.
|
||||
uint32_t addr = idx * blk->blk_size;
|
||||
uint32_t sector = addr_to_sector(addr);
|
||||
// Compute the first page index in the sector to manage the status
|
||||
int idx_sector = sector_addr(sector) / blk->blk_size;
|
||||
|
||||
LOG_INFO("Writing page[%ld]sector[%ld]idx[%d]\n", idx, sector, idx_sector);
|
||||
IRQ_SAVE_DISABLE(flags);
|
||||
|
||||
IapCmd cmd;
|
||||
IapRes res;
|
||||
cmd.cmd = PREPARE_SECTOR_FOR_WRITE;
|
||||
cmd.param[0] = cmd.param[1] = sector;
|
||||
iap(&cmd, &res);
|
||||
|
||||
if (res.status != CMD_SUCCESS)
|
||||
goto flash_error;
|
||||
|
||||
if ((fls->hw->flags & FLASH_WRITE_ONCE) &&
|
||||
bitarray_isRangeFull(&lpc2_bitx, idx_sector, erase_group[sector]))
|
||||
{
|
||||
kputs("blocchi pieni\n");
|
||||
ASSERT(0);
|
||||
goto flash_error;
|
||||
}
|
||||
|
||||
bool erase = false;
|
||||
if ((fls->hw->flags & FLASH_WRITE_ONCE) &&
|
||||
bitarray_isRangeEmpty(&lpc2_bitx, idx_sector, erase_group[sector]))
|
||||
erase = true;
|
||||
|
||||
if (!(fls->hw->flags & FLASH_WRITE_ONCE))
|
||||
erase = true;
|
||||
|
||||
if (erase)
|
||||
{
|
||||
cmd.cmd = ERASE_SECTOR;
|
||||
cmd.param[0] = cmd.param[1] = sector;
|
||||
cmd.param[2] = CPU_FREQ / 1000;
|
||||
iap(&cmd, &res);
|
||||
|
||||
if (res.status != CMD_SUCCESS)
|
||||
goto flash_error;
|
||||
}
|
||||
|
||||
LOG_INFO("Writing page [%ld], addr [%ld] in sector[%ld]\n", idx, addr, sector);
|
||||
cmd.cmd = PREPARE_SECTOR_FOR_WRITE;
|
||||
cmd.param[0] = cmd.param[1] = sector;
|
||||
iap(&cmd, &res);
|
||||
|
||||
if (res.status != CMD_SUCCESS)
|
||||
goto flash_error;
|
||||
|
||||
if (fls->hw->flags & FLASH_WRITE_ONCE)
|
||||
{
|
||||
if (bitarray_test(&lpc2_bitx, idx))
|
||||
{
|
||||
ASSERT(0);
|
||||
goto flash_error;
|
||||
}
|
||||
else
|
||||
bitarray_set(&lpc2_bitx, idx);
|
||||
}
|
||||
|
||||
cmd.cmd = COPY_RAM_TO_FLASH;
|
||||
cmd.param[0] = addr;
|
||||
cmd.param[1] = (uint32_t)buf;
|
||||
cmd.param[2] = FLASH_PAGE_SIZE_BYTES;
|
||||
cmd.param[3] = CPU_FREQ / 1000;
|
||||
iap(&cmd, &res);
|
||||
|
||||
if (res.status != CMD_SUCCESS)
|
||||
goto flash_error;
|
||||
|
||||
IRQ_RESTORE(flags);
|
||||
LOG_INFO("Done\n");
|
||||
|
||||
return blk->blk_size;
|
||||
|
||||
flash_error:
|
||||
IRQ_RESTORE(flags);
|
||||
LOG_ERR("%ld\n", res.status);
|
||||
fls->hw->status |= FLASH_WR_ERR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lpc2_flash_close(UNUSED_ARG(struct KBlock, *blk))
|
||||
{
|
||||
memset(page_dirty, 0, sizeof(page_dirty));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int lpc2_flash_error(struct KBlock *blk)
|
||||
{
|
||||
Flash *fls = FLASH_CAST(blk);
|
||||
return fls->hw->status;
|
||||
}
|
||||
|
||||
static void lpc2_flash_clearerror(struct KBlock *blk)
|
||||
{
|
||||
Flash *fls = FLASH_CAST(blk);
|
||||
fls->hw->status = 0;
|
||||
}
|
||||
|
||||
static const KBlockVTable flash_lpc2_buffered_vt =
|
||||
{
|
||||
.readDirect = lpc2_flash_readDirect,
|
||||
.writeDirect = lpc2_flash_writeDirect,
|
||||
|
||||
.readBuf = kblock_swReadBuf,
|
||||
.writeBuf = kblock_swWriteBuf,
|
||||
.load = kblock_swLoad,
|
||||
.store = kblock_swStore,
|
||||
|
||||
.close = lpc2_flash_close,
|
||||
|
||||
.error = lpc2_flash_error,
|
||||
.clearerr = lpc2_flash_clearerror,
|
||||
};
|
||||
|
||||
static const KBlockVTable flash_lpc2_unbuffered_vt =
|
||||
{
|
||||
.readDirect = lpc2_flash_readDirect,
|
||||
.writeDirect = lpc2_flash_writeDirect,
|
||||
|
||||
.close = lpc2_flash_close,
|
||||
|
||||
.error = lpc2_flash_error,
|
||||
.clearerr = lpc2_flash_clearerror,
|
||||
};
|
||||
|
||||
static struct FlashHardware flash_lpc2_hw;
|
||||
static uint8_t flash_buf[FLASH_PAGE_SIZE_BYTES];
|
||||
|
||||
static void common_init(Flash *fls, int flags)
|
||||
{
|
||||
memset(fls, 0, sizeof(*fls));
|
||||
DB(fls->blk.priv.type = KBT_FLASH);
|
||||
|
||||
fls->hw = &flash_lpc2_hw;
|
||||
fls->hw->flags = flags;
|
||||
|
||||
fls->blk.blk_size = FLASH_PAGE_SIZE_BYTES;
|
||||
fls->blk.blk_cnt = FLASH_MEM_SIZE / FLASH_PAGE_SIZE_BYTES;
|
||||
|
||||
bitarray_init(&lpc2_bitx, FLASH_PAGE_CNT, page_dirty, sizeof(page_dirty));
|
||||
}
|
||||
|
||||
void flash_hw_init(Flash *fls, int flags)
|
||||
{
|
||||
common_init(fls, flags);
|
||||
fls->blk.priv.vt = &flash_lpc2_buffered_vt;
|
||||
fls->blk.priv.flags |= KB_BUFFERED | KB_PARTIAL_WRITE;
|
||||
fls->blk.priv.buf = flash_buf;
|
||||
|
||||
|
||||
/* Load the first block in the cache */
|
||||
void *flash_start = 0x0;
|
||||
memcpy(fls->blk.priv.buf, flash_start, fls->blk.blk_size);
|
||||
}
|
||||
|
||||
void flash_hw_initUnbuffered(Flash *fls, int flags)
|
||||
{
|
||||
common_init(fls, flags);
|
||||
fls->blk.priv.vt = &flash_lpc2_unbuffered_vt;
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
* \brief NPX lpc23xx embedded flash read/write driver.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef FLASH_LPC2_H
|
||||
#define FLASH_LPC2_H
|
||||
|
||||
|
||||
#endif /* DRV_FLASH_ARM_H */
|
@ -1,48 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Low-level I2C module for ARM (interface).
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <cpu/detect.h>
|
||||
|
||||
#if CPU_ARM_AT91
|
||||
#include "i2c_at91.h"
|
||||
#elif CPU_ARM_LPC2378
|
||||
#include "i2c_lpc2.h"
|
||||
/*#elif Add other ARM families here */
|
||||
#else
|
||||
#error Unknown CPU
|
||||
#endif
|
@ -1,54 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Driver for the AT91SAM7X I2C (interface)
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef I2C_AT91_H
|
||||
#define I2C_AT91_H
|
||||
|
||||
#include <drv/i2c.h>
|
||||
|
||||
/**
|
||||
* \name I2C devices enum
|
||||
*/
|
||||
enum
|
||||
{
|
||||
I2C0,
|
||||
|
||||
I2C_CNT /**< Number of serial ports */
|
||||
};
|
||||
|
||||
#endif /* I2C_AT91_H */
|
@ -1,336 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Driver for the LPC23xx I2C (implementation)
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*/
|
||||
|
||||
#include "cfg/cfg_i2c.h"
|
||||
|
||||
#define LOG_LEVEL I2C_LOG_LEVEL
|
||||
#define LOG_FORMAT I2C_LOG_FORMAT
|
||||
|
||||
#include <cfg/log.h>
|
||||
|
||||
#include <cfg/debug.h>
|
||||
#include <cfg/macros.h> // BV()
|
||||
|
||||
#include <cpu/detect.h>
|
||||
#include <cpu/irq.h>
|
||||
#include <cpu/power.h>
|
||||
|
||||
#include <drv/timer.h>
|
||||
#include <drv/i2c.h>
|
||||
|
||||
#include <io/lpc23xx.h>
|
||||
|
||||
struct I2cHardware
|
||||
{
|
||||
uint32_t base;
|
||||
uint32_t pconp;
|
||||
uint32_t pinsel_port;
|
||||
uint32_t pinsel;
|
||||
uint32_t pinsel_mask;
|
||||
uint32_t pclksel;
|
||||
uint32_t pclk_mask;
|
||||
uint32_t pclk_div;
|
||||
};
|
||||
|
||||
/*
|
||||
* Wait that SI bit is set.
|
||||
*
|
||||
* Note: this bit is set when the I2C state changes. However, entering
|
||||
* state F8 does not set SI since there is nothing for an interrupt service
|
||||
* routine to do in that case.
|
||||
*/
|
||||
#define WAIT_SI(i2c) \
|
||||
do { \
|
||||
ticks_t start = timer_clock(); \
|
||||
while( !(HWREG(i2c->hw->base + I2C_CONSET_OFF) & BV(I2CON_SI)) ) \
|
||||
{ \
|
||||
if (timer_clock() - start > ms_to_ticks(CONFIG_I2C_START_TIMEOUT)) \
|
||||
{ \
|
||||
LOG_ERR("Timeout SI assert\n"); \
|
||||
LOG_ERR("[%08lx]\n", HWREG(i2c->hw->base + I2C_STAT_OFF)); \
|
||||
break; \
|
||||
} \
|
||||
cpu_relax(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static void i2c_hw_restart(I2c *i2c)
|
||||
{
|
||||
// Clear all pending flags.
|
||||
HWREG(i2c->hw->base + I2C_CONCLR_OFF) = BV(I2CON_STAC) | BV(I2CON_SIC) | BV(I2CON_AAC);
|
||||
|
||||
// Set start and ack bit.
|
||||
HWREG(i2c->hw->base + I2C_CONSET_OFF) = BV(I2CON_STA);
|
||||
|
||||
WAIT_SI(i2c);
|
||||
}
|
||||
|
||||
|
||||
static void i2c_hw_stop(I2c *i2c)
|
||||
{
|
||||
/* Set the stop bit */
|
||||
HWREG(i2c->hw->base + I2C_CONSET_OFF) = BV(I2CON_STO);
|
||||
/* Clear pending flags */
|
||||
HWREG(i2c->hw->base + I2C_CONCLR_OFF) = BV(I2CON_STAC) | BV(I2CON_SIC) | BV(I2CON_AAC);
|
||||
}
|
||||
|
||||
static void i2c_lpc2_putc(I2c *i2c, uint8_t data)
|
||||
{
|
||||
HWREG(i2c->hw->base + I2C_DAT_OFF) = data;
|
||||
HWREG(i2c->hw->base + I2C_CONCLR_OFF) = BV(I2CON_SIC);
|
||||
|
||||
WAIT_SI(i2c);
|
||||
|
||||
uint32_t status = HWREG(i2c->hw->base + I2C_STAT_OFF);
|
||||
|
||||
|
||||
/* Generate the stop if we finish to send all programmed bytes */
|
||||
if (i2c->xfer_size == 1)
|
||||
{
|
||||
if (I2C_TEST_STOP(i2c->flags) == I2C_STOP)
|
||||
i2c_hw_stop(i2c);
|
||||
}
|
||||
|
||||
if (status == I2C_STAT_DATA_NACK)
|
||||
{
|
||||
LOG_ERR("Data NACK\n");
|
||||
i2c->errors |= I2C_NO_ACK;
|
||||
i2c_hw_stop(i2c);
|
||||
}
|
||||
else if ((status == I2C_STAT_ERROR) || (status == I2C_STAT_UNKNOW))
|
||||
{
|
||||
LOG_ERR("I2C error.\n");
|
||||
i2c->errors |= I2C_ERR;
|
||||
i2c_hw_stop(i2c);
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t i2c_lpc2_getc(I2c *i2c)
|
||||
{
|
||||
/*
|
||||
* Set ack bit if we want read more byte, otherwise
|
||||
* we disable it
|
||||
*/
|
||||
if (i2c->xfer_size > 1)
|
||||
HWREG(i2c->hw->base + I2C_CONSET_OFF) = BV(I2CON_AA);
|
||||
else
|
||||
HWREG(i2c->hw->base + I2C_CONCLR_OFF) = BV(I2CON_AAC);
|
||||
|
||||
HWREG(i2c->hw->base + I2C_CONCLR_OFF) = BV(I2CON_SIC);
|
||||
|
||||
WAIT_SI(i2c);
|
||||
|
||||
uint32_t status = HWREG(i2c->hw->base + I2C_STAT_OFF);
|
||||
uint8_t data = (uint8_t)HWREG(i2c->hw->base + I2C_DAT_OFF);
|
||||
|
||||
if (status == I2C_STAT_RDATA_ACK)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
else if (status == I2C_STAT_RDATA_NACK)
|
||||
{
|
||||
/*
|
||||
* last byte to read generate the stop if
|
||||
* required
|
||||
*/
|
||||
if (I2C_TEST_STOP(i2c->flags) == I2C_STOP)
|
||||
i2c_hw_stop(i2c);
|
||||
|
||||
return data;
|
||||
}
|
||||
else if ((status == I2C_STAT_ERROR) || (status == I2C_STAT_UNKNOW))
|
||||
{
|
||||
LOG_ERR("I2C error.\n");
|
||||
i2c->errors |= I2C_ERR;
|
||||
i2c_hw_stop(i2c);
|
||||
}
|
||||
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
static void i2c_lpc2_start(struct I2c *i2c, uint16_t slave_addr)
|
||||
{
|
||||
if (I2C_TEST_START(i2c->flags) == I2C_START_W)
|
||||
{
|
||||
ticks_t start = timer_clock();
|
||||
while (true)
|
||||
{
|
||||
i2c_hw_restart(i2c);
|
||||
|
||||
uint8_t status = HWREG(i2c->hw->base + I2C_STAT_OFF);
|
||||
|
||||
/* Start status ok, set addres and the R/W bit */
|
||||
if ((status == I2C_STAT_SEND) || (status == I2C_STAT_RESEND))
|
||||
HWREG(i2c->hw->base + I2C_DAT_OFF) = slave_addr & ~I2C_READBIT;
|
||||
|
||||
/* Clear the start bit and clear the SI bit */
|
||||
HWREG(i2c->hw->base + I2C_CONCLR_OFF) = BV(I2CON_SIC) | BV(I2CON_STAC);
|
||||
|
||||
if (status == I2C_STAT_SLAW_ACK)
|
||||
break;
|
||||
|
||||
if (status == I2C_STAT_ARB_LOST)
|
||||
{
|
||||
LOG_ERR("Arbitration lost\n");
|
||||
i2c->errors |= I2C_ARB_LOST;
|
||||
i2c_hw_stop(i2c);
|
||||
}
|
||||
|
||||
if (timer_clock() - start > ms_to_ticks(CONFIG_I2C_START_TIMEOUT))
|
||||
{
|
||||
LOG_ERR("Timeout on I2C START\n");
|
||||
i2c->errors |= I2C_NO_ACK;
|
||||
i2c_hw_stop(i2c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (I2C_TEST_START(i2c->flags) == I2C_START_R)
|
||||
{
|
||||
i2c_hw_restart(i2c);
|
||||
|
||||
uint8_t status = HWREG(i2c->hw->base + I2C_STAT_OFF);
|
||||
|
||||
/* Start status ok, set addres and the R/W bit */
|
||||
if ((status == I2C_STAT_SEND) || (status == I2C_STAT_RESEND))
|
||||
HWREG(i2c->hw->base + I2C_DAT_OFF) = slave_addr | I2C_READBIT;
|
||||
|
||||
/* Clear the start bit and clear the SI bit */
|
||||
HWREG(i2c->hw->base + I2C_CONCLR_OFF) = BV(I2CON_SIC) | BV(I2CON_STAC);
|
||||
|
||||
WAIT_SI(i2c);
|
||||
|
||||
status = HWREG(i2c->hw->base + I2C_STAT_OFF);
|
||||
|
||||
if (status == I2C_STAT_SLAR_NACK)
|
||||
{
|
||||
LOG_ERR("SLAR NACK:%02x\n", status);
|
||||
i2c->errors |= I2C_NO_ACK;
|
||||
i2c_hw_stop(i2c);
|
||||
}
|
||||
|
||||
if (status == I2C_STAT_ARB_LOST)
|
||||
{
|
||||
LOG_ERR("Arbitration lost\n");
|
||||
i2c->errors |= I2C_ARB_LOST;
|
||||
i2c_hw_stop(i2c);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
static const I2cVT i2c_lpc_vt =
|
||||
{
|
||||
.start = i2c_lpc2_start,
|
||||
.getc = i2c_lpc2_getc,
|
||||
.putc = i2c_lpc2_putc,
|
||||
.write = i2c_genericWrite,
|
||||
.read = i2c_genericRead,
|
||||
};
|
||||
|
||||
static struct I2cHardware i2c_lpc2_hw[] =
|
||||
{
|
||||
{ /* I2C0 */
|
||||
.base = I2C0_BASE_ADDR,
|
||||
.pconp = BV(PCONP_PCI2C0),
|
||||
.pinsel_port = PINSEL1_OFF,
|
||||
.pinsel = I2C0_PINSEL,
|
||||
.pinsel_mask = I2C0_PINSEL_MASK,
|
||||
.pclksel = PCLKSEL0_OFF,
|
||||
.pclk_mask = I2C0_PCLK_MASK,
|
||||
.pclk_div = I2C0_PCLK_DIV8,
|
||||
},
|
||||
{ /* I2C1 */
|
||||
.base = I2C1_BASE_ADDR,
|
||||
.pconp = BV(PCONP_PCI2C1),
|
||||
.pinsel_port = PINSEL0_OFF,
|
||||
.pinsel = I2C1_PINSEL,
|
||||
.pinsel_mask = I2C1_PINSEL_MASK,
|
||||
.pclksel = PCLKSEL1_OFF,
|
||||
.pclk_mask = I2C1_PCLK_MASK,
|
||||
.pclk_div = I2C1_PCLK_DIV8,
|
||||
},
|
||||
{ /* I2C2 */
|
||||
.base = I2C2_BASE_ADDR,
|
||||
.pconp = BV(PCONP_PCI2C2),
|
||||
.pinsel_port = PINSEL0_OFF,
|
||||
.pinsel = I2C2_PINSEL,
|
||||
.pinsel_mask = I2C2_PINSEL_MASK,
|
||||
.pclksel = PCLKSEL1_OFF,
|
||||
.pclk_mask = I2C2_PCLK_MASK,
|
||||
.pclk_div = I2C2_PCLK_DIV8,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize I2C module.
|
||||
*/
|
||||
void i2c_hw_init(I2c *i2c, int dev, uint32_t clock)
|
||||
{
|
||||
i2c->hw = &i2c_lpc2_hw[dev];
|
||||
i2c->vt = &i2c_lpc_vt;
|
||||
|
||||
/* Enable I2C clock */
|
||||
PCONP |= i2c->hw->pconp;
|
||||
|
||||
ASSERT(clock <= 400000);
|
||||
|
||||
HWREG(i2c->hw->base + I2C_CONCLR_OFF) = BV(I2CON_I2ENC) | BV(I2CON_STAC) | BV(I2CON_SIC) | BV(I2CON_AAC);
|
||||
|
||||
/*
|
||||
* Bit Frequency = Fplk / (I2C_I2SCLH + I2C_I2SCLL)
|
||||
* value of I2SCLH and I2SCLL must be different
|
||||
*/
|
||||
HWREG(SCB_BASE_ADDR + i2c->hw->pclksel) &= ~i2c->hw->pclk_mask;
|
||||
HWREG(SCB_BASE_ADDR + i2c->hw->pclksel) |= i2c->hw->pclk_div;
|
||||
|
||||
HWREG(i2c->hw->base + I2C_SCLH_OFF) = (((CPU_FREQ / 8) / clock) / 2) + 1;
|
||||
HWREG(i2c->hw->base + I2C_SCLL_OFF) = (((CPU_FREQ / 8) / clock) / 2);
|
||||
|
||||
ASSERT(HWREG(i2c->hw->base + I2C_SCLH_OFF) > 4);
|
||||
ASSERT(HWREG(i2c->hw->base + I2C_SCLL_OFF) > 4);
|
||||
|
||||
/* Assign pins to SCL and SDA */
|
||||
HWREG(PINSEL_BASE_ADDR + i2c->hw->pinsel_port) &= ~i2c->hw->pinsel_mask;
|
||||
HWREG(PINSEL_BASE_ADDR + i2c->hw->pinsel_port) |= i2c->hw->pinsel;
|
||||
|
||||
// Enable I2C
|
||||
HWREG(i2c->hw->base + I2C_CONSET_OFF) = BV(I2CON_I2EN);
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2010 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief Driver for the LPC23xx I2C (interface)
|
||||
*
|
||||
* \author Daniele Basile <asterix@develer.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef I2C_LPC2_H
|
||||
#define I2C_LPC2_H
|
||||
|
||||
#include <drv/i2c.h>
|
||||
|
||||
/**
|
||||
* \name I2C devices enum
|
||||
*/
|
||||
enum
|
||||
{
|
||||
I2C0,
|
||||
I2C1,
|
||||
I2C2,
|
||||
|
||||
I2C_CNT /**< Number of serial ports */
|
||||
};
|
||||
|
||||
#endif /* I2C_LPC2_H */
|
@ -1,185 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2009 Develer S.r.l. (http://www.develer.com/)
|
||||
* -->
|
||||
*
|
||||
* \brief I2S driver implementation.
|
||||
*
|
||||
* \author Luca Ottaviano <lottaviano@develer.com>
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* TODO: Revise the public api of this module to be more generic. Evalutate to
|
||||
* implement the more generic layer to be common to all I2S BeRTOS drivers.
|
||||
*/
|
||||
#include "i2s_at91.h"
|
||||
#include "cfg/cfg_i2s.h"
|
||||
|
||||
// Define log settings for cfg/log.h.
|
||||
#define LOG_LEVEL I2S_LOG_LEVEL
|
||||
#define LOG_FORMAT I2S_LOG_FORMAT
|
||||
#include <cfg/log.h>
|
||||
|
||||
#include <drv/timer.h>
|
||||
#include <io/arm.h>
|
||||
|
||||
#define DATALEN (15 & SSC_DATLEN_MASK)
|
||||
// FIXME: this is not correct for 16 <= DATALEN < 24
|
||||
#define PDC_DIV ((DATALEN / 8) + 1)
|
||||
/*
|
||||
* PDC_DIV must be 1, 2 or 4, which are the bytes that are transferred
|
||||
* each time the PDC reads from memory.
|
||||
*/
|
||||
STATIC_ASSERT(PDC_DIV % 2 == 0);
|
||||
#define PDC_COUNT (CONFIG_PLAY_BUF_LEN / PDC_DIV)
|
||||
|
||||
static uint8_t play_buf1[CONFIG_PLAY_BUF_LEN];
|
||||
static uint8_t play_buf2[CONFIG_PLAY_BUF_LEN];
|
||||
|
||||
// the buffer in PDC next is play_buf2
|
||||
volatile bool is_second_buf_next;
|
||||
|
||||
uint8_t *i2s_getBuffer(unsigned buf_num)
|
||||
{
|
||||
LOG_INFO("getBuffer start\n");
|
||||
|
||||
if (i2s_isPlaying())
|
||||
{
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (buf_num == I2S_SECOND_BUF)
|
||||
return play_buf2;
|
||||
else if (buf_num == I2S_FIRST_BUF)
|
||||
return play_buf1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t *i2s_getFreeBuffer(void)
|
||||
{
|
||||
if (!i2s_isPlaying())
|
||||
{
|
||||
ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// wait PDC transmission end
|
||||
if (!(SSC_SR & BV(SSC_ENDTX)))
|
||||
return 0;
|
||||
|
||||
uint8_t *ret_buf = 0;
|
||||
// the last time we got called, the second buffer was in PDC next
|
||||
if (is_second_buf_next)
|
||||
{
|
||||
is_second_buf_next = false;
|
||||
ret_buf = play_buf1;
|
||||
}
|
||||
// the last time the first buffer was in PDC next
|
||||
else
|
||||
{
|
||||
is_second_buf_next = true;
|
||||
ret_buf = play_buf2;
|
||||
}
|
||||
|
||||
if (ret_buf)
|
||||
{
|
||||
SSC_TNPR = (reg32_t) ret_buf;
|
||||
SSC_TNCR = PDC_COUNT;
|
||||
}
|
||||
return ret_buf;
|
||||
}
|
||||
|
||||
bool i2s_start(void)
|
||||
{
|
||||
/* Some time must pass between disabling and enabling again the transmission
|
||||
* on SSC. A good empirical value seems >15 us. We try to avoid putting an
|
||||
* explicit delay, instead we disable the transmitter when a sound finishes
|
||||
* and hope that the delay has passed before we enter here again.
|
||||
*/
|
||||
SSC_CR = BV(SSC_TXDIS);
|
||||
timer_delay(10);
|
||||
|
||||
SSC_PTCR = BV(PDC_TXTDIS);
|
||||
SSC_TPR = (reg32_t)play_buf1;
|
||||
SSC_TCR = PDC_COUNT;
|
||||
SSC_TNPR = (reg32_t)play_buf2;
|
||||
SSC_TNCR = PDC_COUNT;
|
||||
is_second_buf_next = true;
|
||||
|
||||
SSC_PTCR = BV(PDC_TXTEN);
|
||||
|
||||
/* enable output */
|
||||
SSC_CR = BV(SSC_TXEN);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#define BITS_PER_CHANNEL 16
|
||||
#define N_OF_CHANNEL 2
|
||||
// TODO: check the computed value?
|
||||
/* The last parameter (2) is due to the hadware on at91sam7s. */
|
||||
#define MCK_DIV (CPU_FREQ / CONFIG_SAMPLE_FREQ / BITS_PER_CHANNEL / N_OF_CHANNEL / 2)
|
||||
|
||||
#define CONFIG_DELAY 1
|
||||
#define CONFIG_PERIOD 15
|
||||
#define CONFIG_DATNB 1
|
||||
#define CONFIG_FSLEN 15
|
||||
|
||||
#define DELAY ((CONFIG_DELAY << SSC_STTDLY_SHIFT) & SSC_STTDLY_MASK)
|
||||
#define PERIOD ((CONFIG_PERIOD << (SSC_PERIOD_SHIFT)) & SSC_PERIOD_MASK)
|
||||
#define DATNB ((CONFIG_DATNB << SSC_DATNB_SHIFT) & SSC_DATNB_MASK)
|
||||
#define FSLEN ((CONFIG_FSLEN << SSC_FSLEN_SHIFT) & SSC_FSLEN_MASK)
|
||||
|
||||
#define SSC_DMA_IRQ_PRIORITY 5
|
||||
|
||||
void i2s_init(void)
|
||||
{
|
||||
PIOA_PDR = BV(SSC_TK) | BV(SSC_TF) | BV(SSC_TD);
|
||||
/* reset device */
|
||||
SSC_CR = BV(SSC_SWRST);
|
||||
|
||||
SSC_CMR = MCK_DIV & SSC_DIV_MASK;
|
||||
SSC_TCMR = SSC_CKS_DIV | SSC_CKO_CONT | SSC_CKG_NONE | DELAY | PERIOD | SSC_START_FALL_F;
|
||||
SSC_TFMR = DATALEN | DATNB | FSLEN | BV(SSC_MSBF) | SSC_FSOS_NEGATIVE;
|
||||
|
||||
/* Disable all irqs */
|
||||
SSC_IDR = 0xFFFFFFFF;
|
||||
|
||||
/* Enable the SSC IRQ */
|
||||
AIC_IECR = BV(SSC_ID);
|
||||
|
||||
/* enable i2s */
|
||||
PMC_PCER = BV(SSC_ID);
|
||||
|
||||
/* Enable SSC */
|
||||
SSC_CR = BV(SSC_TXEN);
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2009 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief I2S driver functions.
|
||||
*
|
||||
* This driver uses a double buffering technique to keep i2s bus busy. First fill in the two buffers
|
||||
* using i2s_getBuffer(), then start audio playing with i2s_start(). Then call i2s_getFreeBuffer()
|
||||
* until you have finished your samples. The reproduction will automatically stop if you don't
|
||||
* call i2s_getFreeBuffer() frequently enough.
|
||||
*
|
||||
* Example:
|
||||
* \code
|
||||
* // fill in the buffers before start
|
||||
* buf = i2s_getBuffer(I2S_FIRST_BUF);
|
||||
* // ...
|
||||
* buf = i2s_getBuffer(I2S_SECOND_BUF);
|
||||
* // ...
|
||||
* // here the driver will play only the first two buffers...
|
||||
* i2s_start();
|
||||
* // ...call getFreeBuffer() to continue playing.
|
||||
* while (!(buf = i2s_getFreeBuffer()))
|
||||
* ;
|
||||
* // now fill the buffer again
|
||||
* \endcode
|
||||
*
|
||||
* \author Luca Ottaviano <lottaviano@develer.com>
|
||||
*
|
||||
* $WIZ$ module_name = "i2s"
|
||||
* $WIZ$ module_configuration = "bertos/cfg/cfg_i2s.h"
|
||||
* $WIZ$ module_supports = "at91"
|
||||
*/
|
||||
|
||||
#ifndef DRV_I2S_AT91_H
|
||||
#define DRV_I2S_AT91_H
|
||||
|
||||
|
||||
#include <cfg/compiler.h>
|
||||
#include <cfg/macros.h>
|
||||
#include <io/arm.h>
|
||||
|
||||
/**
|
||||
* First buffer.
|
||||
*/
|
||||
#define I2S_FIRST_BUF 0
|
||||
/**
|
||||
* Second buffer.
|
||||
*/
|
||||
#define I2S_SECOND_BUF 1
|
||||
|
||||
/**
|
||||
* Initializes the module and sets current buffer to I2S_FIRST_BUF.
|
||||
*/
|
||||
void i2s_init(void);
|
||||
|
||||
/**
|
||||
* Returns one of the two buffers or NULL if none is available.
|
||||
*
|
||||
* You can't call this function if you have already started the player.
|
||||
* \param buf_num The number of the buffer, ie I2S_FIRST_BUF or I2S_SECOND_BUF.
|
||||
* \return A pointer to the buffer if the buffer is available (not full), 0 on errors
|
||||
*/
|
||||
uint8_t *i2s_getBuffer(unsigned buf_num);
|
||||
|
||||
/**
|
||||
* Returns a buffer that will be played after the current one.
|
||||
*
|
||||
* You should fill it faster than your reproduction time. You can't call this function
|
||||
* if the player is not running
|
||||
* \return The next buffer to be played, 0 if both are busy.
|
||||
*/
|
||||
uint8_t *i2s_getFreeBuffer(void);
|
||||
|
||||
/**
|
||||
* Starts playing from I2S_FIRST_BUFFER.
|
||||
*
|
||||
* You must have filled both buffers before calling this function. Does nothing if already playing.
|
||||
* \return false on errors, true otherwise.
|
||||
*/
|
||||
bool i2s_start(void);
|
||||
|
||||
INLINE bool i2s_isPlaying(void)
|
||||
{
|
||||
return !(SSC_SR & BV(SSC_TXEMPTY));
|
||||
}
|
||||
|
||||
#endif /* DRV_I2S_AT91_H */
|
@ -1,48 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2007 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
*
|
||||
* \author Francesco Sacchi <batt@develer.com>
|
||||
*
|
||||
* \brief Low-level kdebug module for ARM (inplementation).
|
||||
*/
|
||||
|
||||
#include <cpu/detect.h>
|
||||
|
||||
#if CPU_ARM_AT91
|
||||
#include "kdebug_at91.c"
|
||||
#elif CPU_ARM_LPC2
|
||||
#include "kdebug_lpc2.c"
|
||||
/*#elif Add other ARM families here */
|
||||
#else
|
||||
#error Unknown CPU
|
||||
#endif
|
@ -1,93 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2007 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
* \brief ARM debug support (implementation).
|
||||
*
|
||||
* \author Francesco Sacchi <batt@develer.com>
|
||||
*/
|
||||
|
||||
#include "kdebug_at91.h"
|
||||
#include <hw/hw_cpufreq.h> /* for CPU_FREQ */
|
||||
#include "hw/hw_ser.h" /* Required for bus macros overrides */
|
||||
|
||||
#include "cfg/cfg_debug.h"
|
||||
#include <cfg/macros.h> /* for BV(), DIV_ROUND */
|
||||
|
||||
#include <io/arm.h>
|
||||
|
||||
#if CONFIG_KDEBUG_PORT == KDEBUG_PORT_DBGU
|
||||
#define KDBG_WAIT_READY() while (!(DBGU_SR & BV(US_TXRDY))) {}
|
||||
#define KDBG_WAIT_TXDONE() while (!(DBGU_SR & BV(US_TXEMPTY))) {}
|
||||
|
||||
#define KDBG_WRITE_CHAR(c) do { DBGU_THR = (c); } while(0)
|
||||
|
||||
/* Debug unit is used only for debug purposes so does not generate interrupts. */
|
||||
#define KDBG_MASK_IRQ(old) do { (void)old; } while(0)
|
||||
|
||||
/* Debug unit is used only for debug purposes so does not generate interrupts. */
|
||||
#define KDBG_RESTORE_IRQ(old) do { (void)old; } while(0)
|
||||
|
||||
typedef uint32_t kdbg_irqsave_t;
|
||||
|
||||
#else
|
||||
#error CONFIG_KDEBUG_PORT should be KDEBUG_PORT_DBGU
|
||||
#endif
|
||||
|
||||
|
||||
INLINE void kdbg_hw_init(void)
|
||||
{
|
||||
#if CONFIG_KDEBUG_PORT == KDEBUG_PORT_DBGU
|
||||
/* Disable all DBGU interrupts. */
|
||||
DBGU_IDR = 0xFFFFFFFF;
|
||||
/* Reset DBGU */
|
||||
DBGU_CR = BV(US_RSTRX) | BV(US_RSTTX) | BV(US_RXDIS) | BV(US_TXDIS);
|
||||
/* Set baudrate */
|
||||
DBGU_BRGR = DIV_ROUND(CPU_FREQ, 16 * CONFIG_KDEBUG_BAUDRATE);
|
||||
/* Set DBGU mode to 8 data bits, no parity and 1 stop bit. */
|
||||
DBGU_MR = US_CHMODE_NORMAL | US_CHRL_8 | US_PAR_NO | US_NBSTOP_1;
|
||||
/* Enable DBGU transmitter. */
|
||||
DBGU_CR = BV(US_TXEN);
|
||||
/* Disable PIO on DGBU tx pin. */
|
||||
PIOA_PDR = BV(DTXD);
|
||||
PIOA_ASR = BV(DTXD);
|
||||
|
||||
#if 0 /* Disable Rx for now */
|
||||
/* Enable DBGU receiver. */
|
||||
DBGU_CR = BV(US_RXEN);
|
||||
/* Disable PIO on DGBU rx pin. */
|
||||
PIOA_PDR = BV(DRXD);
|
||||
PIOA_ASR = BV(DRXD);
|
||||
#endif
|
||||
#else
|
||||
#error CONFIG_KDEBUG_PORT should be KDEBUG_PORT_DBGU
|
||||
#endif /* CONFIG_KDEBUG_PORT == KDEBUG_PORT_DBGU */
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/**
|
||||
* \file
|
||||
* <!--
|
||||
* This file is part of BeRTOS.
|
||||
*
|
||||
* Bertos is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*
|
||||
* Copyright 2007 Develer S.r.l. (http://www.develer.com/)
|
||||
*
|
||||
* -->
|
||||
*
|
||||
*
|
||||
* \author Francesco Sacchi <batt@develer.com>
|
||||
*
|
||||
* \brief ARM debug support (interface).
|
||||
*/
|
||||
|
||||
#ifndef DRV_KDEBUG_AT91_H
|
||||
#define DRV_KDEBUG_AT91_H
|
||||
|
||||
/**
|
||||
* \name Values for CONFIG_KDEBUG_PORT.
|
||||
*
|
||||
* Select which hardware UART to use for system debug.
|
||||
*
|
||||
* \{
|
||||
*/
|
||||
#define KDEBUG_PORT_DBGU 0 ///< Debug on Debug Unit.
|
||||
|
||||
#define KDEBUG_PORT_DEFAULT KDEBUG_PORT_DBGU ///< Default debug port.
|
||||
/* \} */
|
||||
|
||||
#endif /* DRV_KDEBUG_AT91_H */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user