Skip to content

Commit

Permalink
remove redundant headers, consolidate in common directory
Browse files Browse the repository at this point in the history
  • Loading branch information
joeycastillo committed Oct 14, 2024
1 parent 8372cef commit e058bca
Show file tree
Hide file tree
Showing 60 changed files with 155 additions and 3,533 deletions.
4 changes: 4 additions & 0 deletions chips/samd11/startup_samd11.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
*/

//-----------------------------------------------------------------------------
#if !__EMSCRIPTEN__
#include "samd11.h"
#endif

//-----------------------------------------------------------------------------
#define DUMMY __attribute__ ((weak, alias ("irq_handler_dummy")))
Expand Down Expand Up @@ -120,6 +122,7 @@ void (* const vectors[])(void) =
//-----------------------------------------------------------------------------
void irq_handler_reset(void)
{
#if !__EMSCRIPTEN__
unsigned int *src, *dst;

src = &_etext;
Expand All @@ -132,6 +135,7 @@ void irq_handler_reset(void)
*dst++ = 0;

SCB->VTOR = (uint32_t)vectors;
#endif

main();

Expand Down
4 changes: 4 additions & 0 deletions chips/samd21/startup_samd21.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
*/

//-----------------------------------------------------------------------------
#if !__EMSCRIPTEN__
#include "samd21.h"
#endif

//-----------------------------------------------------------------------------
#define DUMMY __attribute__ ((weak, alias ("irq_handler_dummy")))
Expand Down Expand Up @@ -138,6 +140,7 @@ void (* const vectors[])(void) =
//-----------------------------------------------------------------------------
void irq_handler_reset(void)
{
#if !__EMSCRIPTEN__
unsigned int *src, *dst;

src = &_etext;
Expand All @@ -150,6 +153,7 @@ void irq_handler_reset(void)
*dst++ = 0;

SCB->VTOR = (uint32_t)vectors;
#endif

main();

Expand Down
4 changes: 4 additions & 0 deletions chips/samd51/startup_samd51.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
*/

//-----------------------------------------------------------------------------
#if !__EMSCRIPTEN__
#include "samd51.h"
#endif

//-----------------------------------------------------------------------------
#define DUMMY __attribute__ ((weak, alias ("irq_handler_dummy")))
Expand Down Expand Up @@ -429,6 +431,7 @@ void (* const vectors[])(void) =
//-----------------------------------------------------------------------------
void irq_handler_reset(void)
{
#if !__EMSCRIPTEN__
unsigned int *src, *dst;

src = &_etext;
Expand All @@ -441,6 +444,7 @@ void irq_handler_reset(void)
*dst++ = 0;

SCB->VTOR = (uint32_t)vectors;
#endif

main();

Expand Down
4 changes: 4 additions & 0 deletions chips/saml21/startup_saml21.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
*/

//-----------------------------------------------------------------------------
#if !__EMSCRIPTEN__
#include "saml21.h"
#endif

//-----------------------------------------------------------------------------
#define DUMMY __attribute__ ((weak, alias ("irq_handler_dummy")))
Expand Down Expand Up @@ -138,6 +140,7 @@ void (* const vectors[])(void) =
//-----------------------------------------------------------------------------
void irq_handler_reset(void)
{
#if !__EMSCRIPTEN__
unsigned int *src, *dst;

src = &_etext;
Expand All @@ -150,6 +153,7 @@ void irq_handler_reset(void)
*dst++ = 0;

SCB->VTOR = (uint32_t)vectors;
#endif

main();

Expand Down
4 changes: 4 additions & 0 deletions chips/saml22/startup_saml22.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
*/

//-----------------------------------------------------------------------------
#if !__EMSCRIPTEN__
#include "saml22.h"
#endif

//-----------------------------------------------------------------------------
#define DUMMY __attribute__ ((weak, alias ("irq_handler_dummy")))
Expand Down Expand Up @@ -134,6 +136,7 @@ void (* const vectors[])(void) =
//-----------------------------------------------------------------------------
void irq_handler_reset(void)
{
#if !__EMSCRIPTEN__
unsigned int *src, *dst;

src = &_etext;
Expand All @@ -146,6 +149,7 @@ void irq_handler_reset(void)
*dst++ = 0;

SCB->VTOR = (uint32_t)vectors;
#endif

main();

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
95 changes: 95 additions & 0 deletions common/hal_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#include <stdbool.h>
#include <stdint.h>
#include "sam.h"

#pragma once
Expand All @@ -53,6 +56,96 @@
#define HAL_GPIO_PMUX_M 12
#define HAL_GPIO_PMUX_N 13

#if __EMSCRIPTEN__

extern bool pin_levels[3][32];

#define HAL_GPIO_PIN(name, port, pin) \
static inline void HAL_GPIO_##name##_set(void) \
{ \
pin_levels[HAL_GPIO_PORT##port][pin] = true; \
(void)HAL_GPIO_##name##_set; \
} \
\
static inline void HAL_GPIO_##name##_clr(void) \
{ \
pin_levels[HAL_GPIO_PORT##port][pin] = false; \
(void)HAL_GPIO_##name##_clr; \
} \
\
static inline void HAL_GPIO_##name##_toggle(void) \
{ \
pin_levels[HAL_GPIO_PORT##port][pin] = !pin_levels[HAL_GPIO_PORT##port][pin]; \
(void)HAL_GPIO_##name##_toggle; \
} \
\
static inline void HAL_GPIO_##name##_write(int value) \
{ \
pin_levels[HAL_GPIO_PORT##port][pin] = !!value; \
(void)HAL_GPIO_##name##_write; \
} \
\
static inline void HAL_GPIO_##name##_drvstr(int value) \
{ \
(void)HAL_GPIO_##name##_write; \
} \
\
static inline void HAL_GPIO_##name##_in(void) \
{ \
(void)HAL_GPIO_##name##_in; \
} \
\
static inline void HAL_GPIO_##name##_out(void) \
{ \
(void)HAL_GPIO_##name##_out; \
} \
\
static inline void HAL_GPIO_##name##_off(void) \
{ \
(void)HAL_GPIO_##name##_off; \
} \
\
static inline void HAL_GPIO_##name##_pullup(void) \
{ \
(void)HAL_GPIO_##name##_pullup; \
} \
\
static inline void HAL_GPIO_##name##_pulldown(void) \
{ \
(void)HAL_GPIO_##name##_pulldown; \
} \
\
static inline int HAL_GPIO_##name##_read(void) \
{ \
return pin_levels[HAL_GPIO_PORT##port][pin]; \
(void)HAL_GPIO_##name##_read; \
} \
\
static inline int HAL_GPIO_##name##_state(void) \
{ \
return 0; \
(void)HAL_GPIO_##name##_state; \
} \
\
static inline void HAL_GPIO_##name##_pmuxen(int mux) \
{ \
(void)HAL_GPIO_##name##_pmuxen; \
} \
\
static inline void HAL_GPIO_##name##_pmuxdis(void) \
{ \
(void)HAL_GPIO_##name##_pmuxdis; \
} \
\
static inline uint8_t HAL_GPIO_##name##_pin(void) \
{ \
return ((HAL_GPIO_PORT##port << 5) | (pin & 0x1f)); \
(void)HAL_GPIO_##name##_pin; \
} \
\

#else

#define HAL_GPIO_PIN(name, port, pin) \
static inline void HAL_GPIO_##name##_set(void) \
{ \
Expand Down Expand Up @@ -161,6 +254,8 @@
} \
\

#endif // __EMSCRIPTEN__

HAL_GPIO_PIN(SWCLK, A, 30)
HAL_GPIO_PIN(SWDIO, A, 31)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions common/sam.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
#pragma once

#if __EMSCRIPTEN__

typedef int generic_clock_generator_t;

#define HAL_GPIO_PMUX_EIC (0)
#define HAL_GPIO_PMUX_ADC (1)
#define HAL_GPIO_PMUX_AC (1)
#define HAL_GPIO_PMUX_PTC (1)
#define HAL_GPIO_PMUX_SERCOM (2)
#define HAL_GPIO_PMUX_SERCOM_ALT (3)

#define DMAC_CHCTRLB_TRIGACT_BLOCK_Val (0)
#define DMAC_CHCTRLB_TRIGACT_BEAT_Val (2)
#define DMAC_CHCTRLB_TRIGACT_TRANSACTION_Val (3)

typedef int DmacDescriptor;

#else

#define HAL_GPIO_PMUX_EIC HAL_GPIO_PMUX_A
#define HAL_GPIO_PMUX_ADC HAL_GPIO_PMUX_B
#define HAL_GPIO_PMUX_AC HAL_GPIO_PMUX_B
Expand Down Expand Up @@ -166,3 +185,5 @@ typedef enum {
GENERIC_CLOCK_11 = GCLK_PCHCTRL_GEN_GCLK11_Val,
} generic_clock_generator_t;
#endif

#endif // __EMSCRIPTEN__
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions common/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@

#pragma once

#if __EMSCRIPTEN__

typedef int tc_instance_details_t;
typedef int tcc_instance_details_t;
typedef int sercom_instance_details_t;

#else

typedef struct {
Tc* tc;
uint32_t clock_enable_mask;
Expand All @@ -52,6 +60,8 @@ typedef struct {
uint8_t interrupt_line;
} sercom_instance_details_t;

#endif

extern const tc_instance_details_t TC_Peripherals[];
extern const uint8_t Num_TC_Instances;
extern const uint8_t TC_First_Index;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit e058bca

Please sign in to comment.