[AVR] Use osal provided OSAL_ST_FREQUENCY instead of redefining it

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7092 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
utzig 2014-07-25 14:09:15 +00:00
parent 689813a2e2
commit 04fdfe40ab
1 changed files with 17 additions and 23 deletions

View File

@ -37,7 +37,7 @@
/** /**
* @brief Platform name. * @brief Platform name.
*/ */
#define PLATFORM_NAME "AVR" #define PLATFORM_NAME "AVR"
/** /**
* @brief Timer maximum value * @brief Timer maximum value
@ -63,38 +63,32 @@
/* Derived constants and error checks. */ /* Derived constants and error checks. */
/*===========================================================================*/ /*===========================================================================*/
#ifdef _NIL_ /* Find the most suitable prescaler setting for the desired OSAL_ST_FREQUENCY */
#define CFG_ST_FREQUENCY NIL_CFG_ST_FREQUENCY #if ((F_CPU / OSAL_ST_FREQUENCY) <= AVR_TIMER_COUNTER_MAX)
#else
#define CFG_ST_FREQUENCY CH_CFG_ST_FREQUENCY
#endif
/* Find the most suitable prescaler setting for the desired CFG_ST_FREQUENCY */
#if ((F_CPU / CFG_ST_FREQUENCY) <= AVR_TIMER_COUNTER_MAX)
#define AVR_TIMER_PRESCALER 1 #define AVR_TIMER_PRESCALER 1
#define AVR_TIMER_PRESCALER_BITS (0 << CS02) | (0 << CS01) | (1 << CS00); /* CLK */ #define AVR_TIMER_PRESCALER_BITS (0<<CS02)|(0<<CS01)|(1<<CS00); /* CLK */
#elif ((F_CPU / CFG_ST_FREQUENCY / 8) <= AVR_TIMER_COUNTER_MAX) #elif ((F_CPU / OSAL_ST_FREQUENCY / 8) <= AVR_TIMER_COUNTER_MAX)
#define AVR_TIMER_PRESCALER 8 #define AVR_TIMER_PRESCALER 8
#define AVR_TIMER_PRESCALER_BITS (0 << CS02) | (1 << CS01) | (0 << CS00); /* CLK/8 */ #define AVR_TIMER_PRESCALER_BITS (0<<CS02)|(1<<CS01)|(0<<CS00); /* CLK/8 */
#elif ((F_CPU / CFG_ST_FREQUENCY / 64) <= AVR_TIMER_COUNTER_MAX) #elif ((F_CPU / OSAL_ST_FREQUENCY / 64) <= AVR_TIMER_COUNTER_MAX)
#define AVR_TIMER_PRESCALER 64 #define AVR_TIMER_PRESCALER 64
#define AVR_TIMER_PRESCALER_BITS (0 << CS02) | (1 << CS01) | (1 << CS00); /* CLK/64 */ #define AVR_TIMER_PRESCALER_BITS (0<<CS02)|(1<<CS01)|(1<<CS00); /* CLK/64 */
#elif ((F_CPU / CFG_ST_FREQUENCY / 256) <= AVR_TIMER_COUNTER_MAX) #elif ((F_CPU / OSAL_ST_FREQUENCY / 256) <= AVR_TIMER_COUNTER_MAX)
#define AVR_TIMER_PRESCALER 256 #define AVR_TIMER_PRESCALER 256
#define AVR_TIMER_PRESCALER_BITS (1 << CS02) | (0 << CS01) | (0 << CS00); /* CLK/256 */ #define AVR_TIMER_PRESCALER_BITS (1<<CS02)|(0<<CS01)|(0<<CS00); /* CLK/256 */
#elif ((F_CPU / CFG_ST_FREQUENCY / 1024) <= AVR_TIMER_COUNTER_MAX) #elif ((F_CPU / OSAL_ST_FREQUENCY / 1024) <= AVR_TIMER_COUNTER_MAX)
#define AVR_TIMER_PRESCALER 1024 #define AVR_TIMER_PRESCALER 1024
#define AVR_TIMER_PRESCALER_BITS (1 << CS02) | (0 << CS01) | (1 << CS00); /* CLK/1024 */ #define AVR_TIMER_PRESCALER_BITS (1<<CS02)|(0<<CS01)|(1<<CS00); /* CLK/1024 */
#else #else
#error "Frequency too low for timer, please set CFG_ST_FREQUENCY to a higher value" #error "Frequency too low for timer, please set OSAL_ST_FREQUENCY to a higher value"
#endif #endif
#define AVR_TIMER_COUNTER (F_CPU / CFG_ST_FREQUENCY / AVR_TIMER_PRESCALER) #define AVR_TIMER_COUNTER (F_CPU / OSAL_ST_FREQUENCY / AVR_TIMER_PRESCALER)
/* Test if CFG_ST_FREQUENCY can be matched exactly using this timer */ /* Test if OSAL_ST_FREQUENCY can be matched exactly using this timer */
#define F_CPU_ (AVR_TIMER_COUNTER * AVR_TIMER_PRESCALER * CFG_ST_FREQUENCY) #define F_CPU_ (AVR_TIMER_COUNTER * AVR_TIMER_PRESCALER * OSAL_ST_FREQUENCY)
#if (F_CPU_ != F_CPU) #if (F_CPU_ != F_CPU)
#warning "CFG_ST_FREQUENCY cannot be generated exactly using timer" #warning "OSAL_ST_FREQUENCY cannot be generated exactly using timer"
#endif #endif
#undef F_CPU_ #undef F_CPU_