Skip to content

Commit

Permalink
Add periph_clock_config.h to handle ifndefs
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Evans committed Aug 16, 2017
1 parent 3f316f3 commit 9d7b86d
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 24 deletions.
25 changes: 1 addition & 24 deletions cpu/samd21/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,9 @@

#include "cpu.h"
#include "periph_conf.h"
#include "periph_clock_config.h"
#include "periph/init.h"

#ifndef CLOCK_8MHZ
#define CLOCK_8MHZ (8000000UL)
#endif

#ifndef CLOCK_XOSC32K
#define CLOCK_XOSC32K (0)
#endif

#ifndef XOSC32_RUNSTDBY
#define XOSC32_RUNSTDBY (0)
#endif

#ifndef GEN1_1MHZ
#define GEN1_1MHZ (1)
#endif

#ifndef GEN2_XOSC32
#define GEN2_XOSC32 (0)
#endif

#ifndef GEN3_ULP32K
#define GEN3_ULP32K (1)
#endif

#ifndef VDD
/**
* @brief Set system voltage level in mV (determines flash wait states)
Expand Down
58 changes: 58 additions & 0 deletions cpu/samd21/include/periph_clock_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2017 Daniel Evans <photonthunder@gmail.com>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup cpu_samd21
* @{
*
* @file
* @brief CPU specific definitions for default clock configuration
*
* @author Daniel Evans <photonthunder@gmail.com>
*/

#ifndef PERIPH_CLOCK_CONFIG_H
#define PERIPH_CLOCK_CONFIG_H

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Default Clock configurations
*/
#ifndef CLOCK_8MHZ
#define CLOCK_8MHZ (8000000UL)
#endif

#ifndef CLOCK_XOSC32K
#define CLOCK_XOSC32K (0)
#endif

#ifndef XOSC32_RUNSTDBY
#define XOSC32_RUNSTDBY (0)
#endif

#ifndef GEN1_1MHZ
#define GEN1_1MHZ (1)
#endif

#ifndef GEN2_XOSC32
#define GEN2_XOSC32 (0)
#endif

#ifndef GEN3_ULP32K
#define GEN3_ULP32K (1)
#endif

#ifdef __cplusplus
}
#endif

#endif /* PERIPH_CLOCK_CONFIG_H */
/** @} */
2 changes: 2 additions & 0 deletions cpu/samd21/periph/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "cpu.h"
#include "periph/rtc.h"
#include "periph_conf.h"
#include "periph_clock_config.h"


/* guard file in case no RTC device was specified */
#if RTC_NUMOF
Expand Down
1 change: 1 addition & 0 deletions cpu/samd21/periph/rtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "cpu.h"
#include "periph/rtt.h"
#include "periph_conf.h"
#include "periph_clock_config.h"

/* guard file in case no RTT device was specified */
#if RTT_NUMOF
Expand Down
1 change: 1 addition & 0 deletions cpu/samd21/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "periph/timer.h"
#include "periph_conf.h"
#include "periph_clock_config.h"

#define ENABLE_DEBUG (0)
#include "debug.h"
Expand Down

0 comments on commit 9d7b86d

Please sign in to comment.