Loading...
Searching...
No Matches
periph_cpu_common.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Freie Universität Berlin
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
19#ifndef PERIPH_CPU_COMMON_H
20#define PERIPH_CPU_COMMON_H
21
22#include <stdbool.h>
23
24#include "bitarithm.h"
25#include "compiler_hints.h"
26#include "cpu.h"
27#include "msp430_regs.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
37#define HAVE_GPIO_T
38typedef uint16_t gpio_t;
44#define GPIO_UNDEF (0xffff)
45
49#define GPIO_PIN(x, y) ((gpio_t)(((x & 0xff) << 8) | (1 << (y & 0x07))))
50
54#define SPI_HWCS(x) (SPI_CS_UNDEF)
55
65#define TIMER_CHANNEL_NUMOF 7
66
71#define HAVE_GPIO_FLANK_T
75typedef enum {
76 GPIO_FALLING = 0xff,
77 GPIO_RISING = 0x00,
78 GPIO_BOTH = 0xab
85enum {
86 P1 = 1,
87 P2 = 2,
88 P3 = 3,
89 P4 = 4,
90 P5 = 5,
91 P6 = 6,
92};
93
100void gpio_periph_mode(gpio_t pin, bool enable);
101
108extern uint32_t msp430_dco_freq;
109
132
161
183
205
227
303
313
317typedef struct {
328
344
354void clock_init(void);
355
362
369
370#ifdef __cplusplus
371}
372#endif
373
374#endif /* PERIPH_CPU_COMMON_H */
gpio_flank_t
Definition periph_cpu.h:180
Helper functions for bit arithmetic.
Common macros and compiler attributes/pragmas configuration.
#define PURE
The function has no effects except the return value and its return value depends only on the paramete...
msp430_main_clock_source_t
Possible clock sources to generate the main clock from.
@ MAIN_CLOCK_SOURCE_XT2CLK
High frequency crystal between 450 kHz and 8 MHz.
@ MAIN_CLOCK_SOURCE_DCOCLK
Internal digitally controlled oscillator (DCO) with RC-type characteristics.
@ MAIN_CLOCK_SOURCE_LFXT1CLK
Low frequency 32.768 kHz or high frequency crystal between 450 kHz and 8 MHz.
uint32_t PURE msp430_submain_clock_freq(void)
Get the configured submain clock frequency.
void clock_init(void)
Call during boot up process to initialize the clock.
msp430_submain_clock_source_t
Possible clock sources to generate the submain clock from.
@ SUBMAIN_CLOCK_SOURCE_LFXT1CLK
Low frequency 32.768 kHz or high frequency crystal between 450 kHz and 8 MHz.
@ SUBMAIN_CLOCK_SOURCE_DCOCLK
Internal digitally controlled oscillator (DCO) with RC-type characteristics.
@ SUBMAIN_CLOCK_SOURCE_XT2CLK
High frequency crystal between 450 kHz and 8 MHz.
msp430_submain_clock_divider_t
Clock dividers for the submain clock.
@ SUBMAIN_CLOCK_DIVIDE_BY_2
Divide the main clock by 2.
@ SUBMAIN_CLOCK_DIVIDE_BY_8
Divide the main clock by 8.
@ SUBMAIN_CLOCK_DIVIDE_BY_1
Divide the main clock by 1.
@ SUBMAIN_CLOCK_DIVIDE_BY_4
Divide the main clock by 4.
msp430_auxiliary_clock_divider_t
Clock dividers for the auxiliary clock.
@ AUXILIARY_CLOCK_DIVIDE_BY_4
Divide the main clock by 4.
@ AUXILIARY_CLOCK_DIVIDE_BY_1
Divide the main clock by 1.
@ AUXILIARY_CLOCK_DIVIDE_BY_2
Divide the main clock by 2.
@ AUXILIARY_CLOCK_DIVIDE_BY_8
Divide the main clock by 8.
uint32_t PURE msp430_auxiliary_clock_freq(void)
Get the configured auxiliary clock frequency.
msp430_timer_clock_source_t
Enumeration of possible clock sources for a timer.
@ TIMER_CLOCK_SOURCE_AUXILIARY_CLOCK
Auxiliary clock as clock source.
@ TIMER_CLOCK_SOURCE_TXCLK
External TxCLK as clock source.
@ TIMER_CLOCK_SOURCE_SUBMAIN_CLOCK
Sub-system master clock as clock source.
@ TIMER_CLOCK_SOURCE_INCLK
External INCLK as clock source.
msp430_main_clock_divider_t
Clock dividers for the main clock.
@ MAIN_CLOCK_DIVIDE_BY_1
Divide the main clock by 1.
@ MAIN_CLOCK_DIVIDE_BY_8
Divide the main clock by 8.
@ MAIN_CLOCK_DIVIDE_BY_2
Divide the main clock by 2.
@ MAIN_CLOCK_DIVIDE_BY_4
Divide the main clock by 4.
uint32_t msp430_dco_freq
The measured DCO frequency.
void default_clock_init(void)
Initialize the basic clock system to provide the main clock, the subsystem clock, and the auxiliary c...
@ P6
PORT 6.
@ P1
PORT 1.
@ P4
PORT 4.
@ P3
PORT 3.
@ P2
PORT 2.
@ P5
PORT 5.
void gpio_periph_mode(gpio_t pin, bool enable)
Enable or disable a pin to be used by peripheral modules.
#define TXSSEL_SMCLK
Sub-system master clock as clock source.
#define TXSSEL_TXCLK
External TxCLK as clock source.
#define TXSSEL_ACLK
Auxiliary clock as clock source.
#define TXSSEL_INCLK
External INCLK as clock source.
#define REG16(ADDR)
Type for 16-bit registers.
Definition periph_gba.h:37
MSP430Fxzy Basic Clock System Parameters.
msp430_main_clock_source_t main_clock_source
The clock source to select for the main clock.
uint32_t lfxt1_frequency
The frequency of the LFXT1 crystal in Hz.
msp430_auxiliary_clock_divider_t auxiliary_clock_divier
Divider of the auxiliary clock.
uint32_t xt2_frequency
The frequency of the XT2 crystal in Hz.
msp430_submain_clock_source_t submain_clock_source
The clock source to select for the submain CPU clock.
uint32_t target_dco_frequency
The target frequency to run the DCO at in Hz.
msp430_submain_clock_divider_t submain_clock_divier
Divider of the submain clock.
bool has_xt2
A high frequency crystal (e.g.
msp430_main_clock_divider_t main_clock_divier
Divider of the main clock.
bool has_r_osc
An external resistor connected to source the current for the DCO.
Timer peripheral registers.
Timer device configuration.
Definition periph_cpu.h:264
msp430_timer_t * timer
Hardware timer to use.
REG16 * irq_flags
"Timer interrupt vector" register
msp430_timer_clock_source_t clock_source
Clock source to use.