Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Arduino Core for SAMD21 CPU
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
josc941e
Arduino Core for SAMD21 CPU
Commits
d36587e4
Commit
d36587e4
authored
7 years ago
by
Martino Facchin
Committed by
Cristian Maglie
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix exploded binary size
parent
5ce5e43c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bootloaders/zero/board_driver_i2c.c
+1
-7
1 addition, 7 deletions
bootloaders/zero/board_driver_i2c.c
bootloaders/zero/board_driver_i2c.h
+4
-2
4 additions, 2 deletions
bootloaders/zero/board_driver_i2c.h
bootloaders/zero/main.c
+25
-17
25 additions, 17 deletions
bootloaders/zero/main.c
with
30 additions
and
26 deletions
bootloaders/zero/board_driver_i2c.c
+
1
−
7
View file @
d36587e4
...
@@ -71,12 +71,6 @@ static inline void pin_set_peripheral_function(uint32_t pinmux)
...
@@ -71,12 +71,6 @@ static inline void pin_set_peripheral_function(uint32_t pinmux)
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void
i2c_init
(
int
freq
)
void
i2c_init
(
int
freq
)
{
{
int
baud
=
((
float
)
F_CPU
/
freq
-
(
float
)
F_CPU
*
T_RISE
-
10
.
0
)
/
2
.
0
;
if
(
baud
<
0
)
baud
=
0
;
else
if
(
baud
>
255
)
baud
=
255
;
PM
->
APBCMASK
.
reg
|=
I2C_SERCOM_APBCMASK
;
PM
->
APBCMASK
.
reg
|=
I2C_SERCOM_APBCMASK
;
...
@@ -89,7 +83,7 @@ void i2c_init(int freq)
...
@@ -89,7 +83,7 @@ void i2c_init(int freq)
I2C_SERCOM
->
I2CM
.
CTRLB
.
reg
=
SERCOM_I2CM_CTRLB_SMEN
;
I2C_SERCOM
->
I2CM
.
CTRLB
.
reg
=
SERCOM_I2CM_CTRLB_SMEN
;
while
(
I2C_SERCOM
->
I2CM
.
SYNCBUSY
.
reg
);
while
(
I2C_SERCOM
->
I2CM
.
SYNCBUSY
.
reg
);
I2C_SERCOM
->
I2CM
.
BAUD
.
reg
=
SERCOM_I2CM_BAUD_BAUD
(
baud
);
I2C_SERCOM
->
I2CM
.
BAUD
.
reg
=
SERCOM_I2CM_BAUD_BAUD
(
48
);
while
(
I2C_SERCOM
->
I2CM
.
SYNCBUSY
.
reg
);
while
(
I2C_SERCOM
->
I2CM
.
SYNCBUSY
.
reg
);
I2C_SERCOM
->
I2CM
.
CTRLA
.
reg
=
SERCOM_I2CM_CTRLA_ENABLE
|
I2C_SERCOM
->
I2CM
.
CTRLA
.
reg
=
SERCOM_I2CM_CTRLA_ENABLE
|
...
...
This diff is collapsed.
Click to expand it.
bootloaders/zero/board_driver_i2c.h
+
4
−
2
View file @
d36587e4
...
@@ -17,8 +17,8 @@
...
@@ -17,8 +17,8 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
*/
#ifndef _BOARD_DRIVER_
LED
_
#ifndef _BOARD_DRIVER_
I2C
_
#define _BOARD_DRIVER_
LED
_
#define _BOARD_DRIVER_
I2C
_
#include
<sam.h>
#include
<sam.h>
#include
<stdbool.h>
#include
<stdbool.h>
...
@@ -40,4 +40,6 @@
...
@@ -40,4 +40,6 @@
#define FAULT_REGISTER 0x09
#define FAULT_REGISTER 0x09
#define PMIC_VERSION_REGISTER 0x0A
#define PMIC_VERSION_REGISTER 0x0A
void
configure_pmic
();
#endif // _BOARD_DRIVER_LED_
#endif // _BOARD_DRIVER_LED_
This diff is collapsed.
Click to expand it.
bootloaders/zero/main.c
+
25
−
17
View file @
d36587e4
...
@@ -23,18 +23,33 @@
...
@@ -23,18 +23,33 @@
#include
"sam_ba_serial.h"
#include
"sam_ba_serial.h"
#include
"board_definitions.h"
#include
"board_definitions.h"
#include
"board_driver_led.h"
#include
"board_driver_led.h"
#include
"board_driver_i2c.h"
#include
"sam_ba_usb.h"
#include
"sam_ba_usb.h"
#include
"sam_ba_cdc.h"
#include
"sam_ba_cdc.h"
extern
uint32_t
__sketch_vectors_ptr
;
// Exported value from linker script
extern
uint32_t
__sketch_vectors_ptr
;
// Exported value from linker script
extern
void
board_init
(
void
);
extern
void
board_init
(
void
);
#if (defined DEBUG) && (DEBUG == 1)
volatile
uint32_t
*
pulSketch_Start_Address
;
volatile
uint32_t
*
pulSketch_Start_Address
;
#endif
static
void
jump_to_application
(
void
)
{
/* Rebase the Stack Pointer */
__set_MSP
(
(
uint32_t
)(
__sketch_vectors_ptr
)
);
/* Rebase the vector table base address */
SCB
->
VTOR
=
((
uint32_t
)(
&
__sketch_vectors_ptr
)
&
SCB_VTOR_TBLOFF_Msk
);
/* Jump to application Reset Handler in the application */
asm
(
"bx %0"
::
"r"
(
*
pulSketch_Start_Address
));
}
static
volatile
bool
main_b_cdc_enable
=
false
;
static
volatile
bool
main_b_cdc_enable
=
false
;
#ifdef CONFIGURE_PMIC
static
volatile
bool
jump_to_app
=
false
;
#endif
/**
/**
* \brief Check the application startup condition
* \brief Check the application startup condition
*
*
...
@@ -44,10 +59,6 @@ static void check_start_application(void)
...
@@ -44,10 +59,6 @@ static void check_start_application(void)
// LED_init();
// LED_init();
// LED_off();
// LED_off();
#if (!defined DEBUG) || ((defined DEBUG) && (DEBUG == 0))
uint32_t
*
pulSketch_Start_Address
;
#endif
/*
/*
* Test sketch stack pointer @ &__sketch_vectors_ptr
* Test sketch stack pointer @ &__sketch_vectors_ptr
* Stay in SAM-BA if value @ (&__sketch_vectors_ptr) == 0xFFFFFFFF (Erased flash cell value)
* Stay in SAM-BA if value @ (&__sketch_vectors_ptr) == 0xFFFFFFFF (Erased flash cell value)
...
@@ -130,15 +141,12 @@ uint32_t* pulSketch_Start_Address;
...
@@ -130,15 +141,12 @@ uint32_t* pulSketch_Start_Address;
*/
*/
// LED_on();
// LED_on();
#ifdef CONFIGURE_PMIC
jump_to_app
=
true
;
#else
jump_to_application
();
#endif
/* Rebase the Stack Pointer */
__set_MSP
(
(
uint32_t
)(
__sketch_vectors_ptr
)
);
/* Rebase the vector table base address */
SCB
->
VTOR
=
((
uint32_t
)(
&
__sketch_vectors_ptr
)
&
SCB_VTOR_TBLOFF_Msk
);
/* Jump to application Reset Handler in the application */
asm
(
"bx %0"
::
"r"
(
*
pulSketch_Start_Address
));
}
}
#if DEBUG_ENABLE
#if DEBUG_ENABLE
...
@@ -160,10 +168,8 @@ int main(void)
...
@@ -160,10 +168,8 @@ int main(void)
#endif
#endif
DEBUG_PIN_HIGH
;
DEBUG_PIN_HIGH
;
#ifndef CONFIGURE_PMIC
/* Jump in application if condition is satisfied */
/* Jump in application if condition is satisfied */
check_start_application
();
check_start_application
();
#endif
/* We have determined we should stay in the monitor. */
/* We have determined we should stay in the monitor. */
/* System initialization */
/* System initialization */
...
@@ -172,7 +178,9 @@ int main(void)
...
@@ -172,7 +178,9 @@ int main(void)
#ifdef CONFIGURE_PMIC
#ifdef CONFIGURE_PMIC
configure_pmic
();
configure_pmic
();
check_start_application
();
if
(
jump_to_app
==
true
)
{
jump_to_application
();
}
#endif
#endif
#if SAM_BA_INTERFACE == SAM_BA_UART_ONLY || SAM_BA_INTERFACE == SAM_BA_BOTH_INTERFACES
#if SAM_BA_INTERFACE == SAM_BA_UART_ONLY || SAM_BA_INTERFACE == SAM_BA_BOTH_INTERFACES
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment