forked from meesokim/spc1000
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
277 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#include <stdint.h> | ||
|
||
#include "lib.h" | ||
|
||
/*returns the core number*/ | ||
//todo: find how much memeory is used for typedefining and convert to uint32_t | ||
uint32_t get_core_number(void) | ||
{ | ||
uint32_t core_num; | ||
asm volatile ("mrc p15, 0, %0, c0, c0, 5" : "=r" (core_num)); | ||
|
||
return (core_num & CORE_MASK); | ||
} | ||
|
||
/*start secondary core 1*/ | ||
void start_core1(void (*func)(void)) | ||
{ | ||
store32(CORE1_STARTADDRESS, (uint32_t)func); | ||
} | ||
|
||
/*start secondary core 2*/ | ||
void start_core2(void (*func)(void)) | ||
{ | ||
store32(CORE2_STARTADDRESS, (uint32_t)func); | ||
} | ||
|
||
/*start secondary core 3*/ | ||
void start_core3(void (*func)(void)) | ||
{ | ||
store32(CORE3_STARTADDRESS, (uint32_t)func); | ||
} | ||
|
||
/*loads or reads the value from the address*/ | ||
uint32_t load32(uint32_t address) | ||
{ | ||
return *(uint32_t *) address; | ||
} | ||
|
||
/*stores or writes the value from the address*/ | ||
void store32(uint32_t address, uint32_t value) | ||
{ | ||
*(uint32_t *) address = value; | ||
} | ||
|
||
void uart_init(void) | ||
{ | ||
|
||
} | ||
|
||
void enable_JTAG(void) | ||
{ | ||
volatile uint32_t tmp; | ||
|
||
tmp = ARM_GPIO_GPFSEL2; | ||
|
||
tmp &= ~(7<<6); //clear the 3 bits | ||
tmp |= 3 << 6; //TRST | GPIO22 (ALT4) | ||
|
||
tmp &= ~(7<<18); //clear the 3 bits | ||
tmp |= 3 << 18; //TDI | GPIO26 (ALT4) | ||
|
||
tmp &= ~(7<<21); //clear the 3 bits | ||
tmp |= 3 << 21; //TMS | GPIO27 (ALT4) | ||
|
||
tmp &= ~(7<<15); //clear the 3 bits | ||
tmp |= 3 << 15; //TCK | GPIO25 (ALT4) | ||
|
||
tmp &= ~(7<<12); //clear the 3 bits | ||
tmp |= 3 << 12; //TDO | GPIO24 (ALT4) | ||
|
||
ARM_GPIO_GPFSEL2 |= tmp; | ||
} | ||
|
||
//http://www.unixwiz.net/techtips/gnu-c-attributes.html#format | ||
/* todo: enable me | ||
#ifdef NDEBUG | ||
#define debug_printf(...) do { } while(0) | ||
#else | ||
int debug_printf(const char *fmt, ...) __attribute__((format (printf, 1, 2))); | ||
#endif | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef LIB_H | ||
#define LIB_H | ||
|
||
//#include "memio.h" | ||
#include <circle/bcm2835.h> | ||
|
||
#define RPI 2 | ||
#define RPI1 1 | ||
#define RPI2 2 | ||
|
||
#define CORE_MASK 3 | ||
|
||
#define CORE0 0 | ||
#define CORE1 1 | ||
#define CORE2 2 | ||
#define CORE3 3 | ||
|
||
#define CORE1_STARTADDRESS 0x4000009C | ||
#define CORE2_STARTADDRESS 0x400000AC | ||
#define CORE3_STARTADDRESS 0x400000BC | ||
|
||
#define ARM_GPIO_GPFSEL2 (*(volatile uint32_t *)(ARM_GPIO_BASE + 0x08)) | ||
//ACT LED is on GPIO47 (GPIO Function Select 4) | ||
#define ENABLE_ACT_LED() ARM_GPIO_GPFSEL4 |= 1 << 21; | ||
|
||
#define ACT_LED_ON() ARM_GPIO_GPSET1 |= 1 << 15; | ||
#define ACT_LED_OFF() ARM_GPIO_GPCLR1 |= 1 << 15; | ||
|
||
uint32_t get_core_number(void); | ||
void start_core1(void (*func)(void)); | ||
void start_core2(void (*func)(void)); | ||
void start_core3(void (*func)(void)); | ||
|
||
void enable_JTAG(void); | ||
|
||
uint32_t load32(uint32_t address); | ||
void store32(uint32_t address, uint32_t value); | ||
|
||
#endif //LIB_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.