SWM050: Finishes GPIO, IAP flash, sysclock, sleep/stop, and the sysctl memory map.
Updates the main memory map and the makefile. Adds the SWM050 to devices.data, so that a linker script can be automatically generated. Reviewed-by: Karl Palsson <karlp@tweak.net.au>
This commit is contained in:
committed by
Karl Palsson
parent
1fbfdecb17
commit
3c4ee6f4c0
55
include/libopencm3/swm050/clk.h
Normal file
55
include/libopencm3/swm050/clk.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/** @defgroup clk_defines Clock Defines
|
||||
*
|
||||
* @brief <b>Defined Constants and Types for the SWM050 System Clock</b>
|
||||
*
|
||||
* @ingroup SWM050_defines
|
||||
*
|
||||
* LGPL License Terms @ref lgpl_license
|
||||
*/
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* Copyright (C) 2019 Caleb Szalacinski <contact@skiboy.net>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**@{*/
|
||||
#ifndef LIBOPENCM3_CLK_H
|
||||
#define LIBOPENCM3_CLK_H
|
||||
#include <libopencm3/cm3/common.h>
|
||||
#include <libopencm3/swm050/memorymap.h>
|
||||
|
||||
/* Clock speed definitions */
|
||||
/** @defgroup clk_speeds Base Clock Speeds
|
||||
@{*/
|
||||
enum clk_speeds {
|
||||
CLK_18MHZ,
|
||||
CLK_36MHZ
|
||||
};
|
||||
/*@}*/
|
||||
|
||||
/* Clock divider mask */
|
||||
/** @defgroup clk_mask Mask used to set the clock divider
|
||||
@{*/
|
||||
#define CLK_MASK 0xFFFFFC00
|
||||
/*@}*/
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
void clk_speed(enum clk_speeds mhz, uint16_t div);
|
||||
|
||||
END_DECLS
|
||||
|
||||
#endif
|
||||
/**@}*/
|
||||
42
include/libopencm3/swm050/flash.h
Normal file
42
include/libopencm3/swm050/flash.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/** @defgroup flash_defines Flash Defines
|
||||
*
|
||||
* @brief <b>Defined Constants and Types for the SWM050 Flash API</b>
|
||||
*
|
||||
* @ingroup SWM050_defines
|
||||
*
|
||||
* LGPL License Terms @ref lgpl_license
|
||||
*/
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* Copyright (C) 2019 Caleb Szalacinski <contact@skiboy.net>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**@{*/
|
||||
#ifndef LIBOPENCM3_FLASH_H
|
||||
#define LIBOPENCM3_FLASH_H
|
||||
|
||||
#include <libopencm3/cm3/common.h>
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
uint32_t flash_write(uint32_t *dest, uint32_t *src, uint8_t cnt);
|
||||
uint32_t flash_read(uint32_t *src, uint32_t *dest, uint8_t cnt);
|
||||
uint32_t flash_erase(void);
|
||||
|
||||
END_DECLS
|
||||
|
||||
#endif
|
||||
/**@}*/
|
||||
@@ -10,6 +10,7 @@
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* Copyright (C) 2019 Icenowy Zheng <icenowy@aosc.io>
|
||||
* Copyright (C) 2019 Caleb Szalacinski <contact@skiboy.net>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -24,18 +25,14 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**@{*/
|
||||
|
||||
#ifndef LIBOPENCM3_GPIO_H
|
||||
#define LIBOPENCM3_GPIO_H
|
||||
|
||||
#include <libopencm3/cm3/common.h>
|
||||
#include <libopencm3/swm050/memorymap.h>
|
||||
|
||||
/* GPIO number definitions (for convenience) */
|
||||
/** @defgroup gpio_pin_id GPIO Pin Identifiers
|
||||
|
||||
@{*/
|
||||
#define GPIO0 (1 << 0)
|
||||
#define GPIO1 (1 << 1)
|
||||
@@ -53,46 +50,62 @@
|
||||
/* GPIO direction definitions */
|
||||
/** @defgroup gpio_dir GPIO Pin Direction
|
||||
@{*/
|
||||
#define GPIO_INPUT 0x0
|
||||
#define GPIO_OUTPUT 0x1
|
||||
enum gpio_dir {
|
||||
GPIO_INPUT,
|
||||
GPIO_OUTPUT
|
||||
};
|
||||
/**@}*/
|
||||
|
||||
/* GPIO polarity definitions */
|
||||
/** @defgroup gpio_pol GPIO Polarity
|
||||
@{*/
|
||||
enum gpio_pol {
|
||||
GPIO_POL_LOW,
|
||||
GPIO_POL_HIGH
|
||||
};
|
||||
/*@}*/
|
||||
|
||||
/* GPIO interrupt trigger definitions */
|
||||
/** @defgroup gpio_trig_type GPIO Interrupt Trigger Type
|
||||
@{*/
|
||||
enum gpio_trig_type {
|
||||
GPIO_TRIG_LEVEL,
|
||||
GPIO_TRIG_EDGE
|
||||
};
|
||||
/*@}*/
|
||||
|
||||
/* GPIO interrupt mask definitions */
|
||||
/** @defgroup gpio_int_masked GPIO Interrupt Mask
|
||||
@{*/
|
||||
enum gpio_int_masked {
|
||||
GPIO_UNMASKED,
|
||||
GPIO_MASKED
|
||||
};
|
||||
/*@}*/
|
||||
|
||||
/* GPIO Registers */
|
||||
/** @defgroup gpio_registers GPIO Registers
|
||||
@{*/
|
||||
/** Data register */
|
||||
#define GPIO_DATA MMIO32(GPIO_BASE + 0x0)
|
||||
#define GPIO_ADATA MMIO32(GPIO_BASE + 0x0)
|
||||
/** Direction register */
|
||||
#define GPIO_DIR MMIO32(GPIO_BASE + 0x4)
|
||||
#define GPIO_ADIR MMIO32(GPIO_BASE + 0x4)
|
||||
/** Interrupt enable register */
|
||||
#define GPIO_INTEN MMIO32(GPIO_BASE + 0x30)
|
||||
#define GPIO_INTEN_A MMIO32(GPIO_BASE + 0x30)
|
||||
/** Interrupt mask register */
|
||||
#define GPIO_INTMASK MMIO32(GPIO_BASE + 0x34)
|
||||
#define GPIO_INTMASK_A MMIO32(GPIO_BASE + 0x34)
|
||||
/** Interrupt trigger mode register */
|
||||
#define GPIO_INTLEVEL MMIO32(GPIO_BASE + 0x38)
|
||||
#define GPIO_INTLEVEL_A MMIO32(GPIO_BASE + 0x38)
|
||||
/** Interrupt polarity register */
|
||||
#define GPIO_INTPOLARITY MMIO32(GPIO_BASE + 0x3c)
|
||||
#define GPIO_INTPOLARITY_A MMIO32(GPIO_BASE + 0x3c)
|
||||
/** Interrupt status after masking */
|
||||
#define GPIO_INTSTATUS MMIO32(GPIO_BASE + 0x40)
|
||||
#define GPIO_INTSTAT_A MMIO32(GPIO_BASE + 0x40)
|
||||
/** Interrupt status before masking */
|
||||
#define GPIO_INTRAWSTATUS MMIO32(GPIO_BASE + 0x44)
|
||||
#define GPIO_RAWINTSTAT_A MMIO32(GPIO_BASE + 0x44)
|
||||
/** Interrupt clear register */
|
||||
#define GPIO_INTEOI MMIO32(GPIO_BASE + 0x48)
|
||||
#define GPIO_INTEOI_A MMIO32(GPIO_BASE + 0x48)
|
||||
/** External register (wat) */
|
||||
#define GPIO_EXT MMIO32(GPIO_BASE + 0x4c)
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** @defgroup syscon_register SYSCON Registers
|
||||
* @note These registers are really part of the SYSCON system control space
|
||||
* @{*/
|
||||
/** SWD Enable register */
|
||||
#define SWD_SEL MMIO32(SYSTEM_CON_BASE + 0x30)
|
||||
/** GPIO Alternat function selection register */
|
||||
#define GPIO_SEL MMIO32(SYSTEM_CON_BASE + 0x80)
|
||||
/** GPIO Pull up register */
|
||||
#define GPIO_PULLUP MMIO32(SYSTEM_CON_BASE + 0x90)
|
||||
/** GPIO Input enable register */
|
||||
#define GPIO_INEN MMIO32(SYSTEM_CON_BASE + 0xe0)
|
||||
#define GPIO_AEXT MMIO32(GPIO_BASE + 0x4c)
|
||||
/*@}*/
|
||||
|
||||
BEGIN_DECLS
|
||||
@@ -104,13 +117,16 @@ void gpio_toggle(uint16_t gpios);
|
||||
|
||||
void gpio_input(uint16_t gpios);
|
||||
void gpio_output(uint16_t gpios);
|
||||
void gpio_sel_af(uint16_t gpios, bool af_en);
|
||||
void gpio_pullup(uint16_t gpios, bool en);
|
||||
void gpio_in_en(uint16_t gpios, bool en);
|
||||
|
||||
void gpio_sel_swd(bool en);
|
||||
void gpio_int_enable(uint16_t gpios, bool en);
|
||||
void gpio_int_mask(uint16_t gpios, enum gpio_int_masked masked);
|
||||
void gpio_int_type(uint16_t gpios, enum gpio_trig_type type);
|
||||
void gpio_int_pol(uint16_t gpios, enum gpio_pol pol);
|
||||
uint16_t gpio_int_status(void);
|
||||
uint16_t gpio_int_raw_status(void);
|
||||
void gpio_int_clear(uint16_t gpios);
|
||||
|
||||
END_DECLS
|
||||
|
||||
#endif
|
||||
/**@}*/
|
||||
/**@}*/
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/** @defgroup mmap_defines Memory Map
|
||||
*
|
||||
* @brief <b>Defined Constants for the SWM050 Memory Map</b>
|
||||
*
|
||||
* @ingroup SWM050_defines
|
||||
*
|
||||
* LGPL License Terms @ref lgpl_license
|
||||
*/
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
@@ -16,13 +24,14 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**@{*/
|
||||
#ifndef LIBOPENCM3_MEMORYMAP_H
|
||||
#define LIBOPENCM3_MEMORYMAP_H
|
||||
|
||||
#include <libopencm3/cm3/memorymap.h>
|
||||
|
||||
/* Memory map for all buses */
|
||||
/** @defgroup memory_map Memory Map for All Buses
|
||||
@{*/
|
||||
#define PERIPH_BASE (0x40000000U)
|
||||
|
||||
#define SYSTEM_CON_BASE (PERIPH_BASE + 0x0)
|
||||
@@ -31,5 +40,7 @@
|
||||
#define TIMER_SE1_BASE (PERIPH_BASE + 0x2400)
|
||||
#define WDT_BASE (PERIPH_BASE + 0x19000)
|
||||
#define SYSCTL_BASE (PERIPH_BASE + 0xf0000)
|
||||
/*@}*/
|
||||
|
||||
#endif
|
||||
/**@}*/
|
||||
|
||||
40
include/libopencm3/swm050/pwr.h
Normal file
40
include/libopencm3/swm050/pwr.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/** @defgroup pwr_defines Power/Sleep Defines
|
||||
*
|
||||
* @brief <b>Defined Constants and Types for the SWM050 Power/Sleep API</b>
|
||||
*
|
||||
* @ingroup SWM050_defines
|
||||
*
|
||||
* LGPL License Terms @ref lgpl_license
|
||||
*/
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* Copyright (C) 2019 Caleb Szalacinski <contact@skiboy.net>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**@{*/
|
||||
#ifndef LIBOPENCM3_PWR_H
|
||||
#define LIBOPENCM3_PWR_H
|
||||
#include <libopencm3/cm3/common.h>
|
||||
#include <libopencm3/swm050/memorymap.h>
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
void pwr_sleep(void);
|
||||
|
||||
END_DECLS
|
||||
|
||||
#endif
|
||||
/**@}*/
|
||||
57
include/libopencm3/swm050/syscon.h
Normal file
57
include/libopencm3/swm050/syscon.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/** @defgroup syscon_defines SYSCON Defines
|
||||
*
|
||||
* @brief <b>Defined Constants and Types for the SWM050 SYSCON peripheral</b>
|
||||
*
|
||||
* @ingroup SWM050_defines
|
||||
*
|
||||
* LGPL License Terms @ref lgpl_license
|
||||
*/
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* Copyright (C) 2019 Icenowy Zheng <icenowy@aosc.io>
|
||||
* Copyright (C) 2019 Caleb Szalacinski <contact@skiboy.net>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**@{*/
|
||||
#ifndef LIBOPENCM3_SYSCON_H
|
||||
#define LIBOPENCM3_SYSCON_H
|
||||
#include <libopencm3/cm3/common.h>
|
||||
#include <libopencm3/swm050/memorymap.h>
|
||||
|
||||
/* SYSCON Registers */
|
||||
/** @defgroup syscon_registers SYSCON Registers
|
||||
@{*/
|
||||
/** SWD Enable register */
|
||||
#define SYSCON_SWD_SEL MMIO32(SYSTEM_CON_BASE + 0x30)
|
||||
/** Pin Alternate function selection register */
|
||||
#define SYSCON_PORTA_SEL MMIO32(SYSTEM_CON_BASE + 0x80)
|
||||
/** Pin Pull up register */
|
||||
#define SYSCON_PORTA_PULLUP MMIO32(SYSTEM_CON_BASE + 0x90)
|
||||
/** Pin Input enable register */
|
||||
#define SYSCON_PORTA_INEN MMIO32(SYSTEM_CON_BASE + 0xe0)
|
||||
/*@}*/
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
void syscon_sel_af(uint16_t gpios, bool af_en);
|
||||
void syscon_pullup(uint16_t gpios, bool en);
|
||||
void syscon_input_enable(uint16_t gpios, bool en);
|
||||
void syscon_sel_swd(bool en);
|
||||
|
||||
END_DECLS
|
||||
|
||||
#endif
|
||||
/**@}*/
|
||||
50
include/libopencm3/swm050/sysctl.h
Normal file
50
include/libopencm3/swm050/sysctl.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/** @defgroup sysctl_defines SYSCTL Defines
|
||||
*
|
||||
* @brief <b>Defined Constants and Types for the SWM050 SYSCTL Registers</b>
|
||||
*
|
||||
* @ingroup SWM050_defines
|
||||
*
|
||||
* LGPL License Terms @ref lgpl_license
|
||||
*/
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* Copyright (C) 2019 Caleb Szalacinski <contact@skiboy.net>
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**@{*/
|
||||
#ifndef LIBOPENCM3_SYSCTL_H
|
||||
#define LIBOPENCM3_SYSCTL_H
|
||||
#include <libopencm3/cm3/common.h>
|
||||
#include <libopencm3/swm050/memorymap.h>
|
||||
|
||||
/** @defgroup sysctl_register SYSCTL Registers
|
||||
* @note System configuration registers
|
||||
* @{*/
|
||||
/** Clock dividers for TIMERSE and SCLK */
|
||||
#define SYSCTL_SYS_CFG_0 MMIO32(SYSCTL_BASE + 0x0)
|
||||
/** TIMERSE0, TIMERSE1, and WDT enable */
|
||||
#define SYSCTL_SYS_CFG_1 MMIO32(SYSCTL_BASE + 0x4)
|
||||
/** SCLK multiplier (18Mhz and 36Mhz) */
|
||||
#define SYSCTL_SYS_DBLF MMIO32(SYSCTL_BASE + 0x8)
|
||||
/** MOS Disconnect (Synwit says that this subregister is unused), Sleep Mode,
|
||||
and Internal Oscillator Disconnect. Oscillator Disconnect should probably
|
||||
not be used on the SWM050, because it has no external oscillator support */
|
||||
#define SYSCTL_SYS_CFG_2 MMIO32(SYSCTL_BASE + 0xC)
|
||||
/*@}*/
|
||||
|
||||
#endif
|
||||
/**@}*/
|
||||
Reference in New Issue
Block a user