-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from boochow/rpi
from rpi branch
- Loading branch information
Showing
30 changed files
with
1,269 additions
and
92 deletions.
There are no files selected for viewing
Submodule micropython
updated
297 files
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,23 @@ | ||
#include <stdint.h> | ||
#include "bcm283x_clockmgr.h" | ||
|
||
void clockmgr_pause(clockmgr_t *clk) { | ||
if (clk->CTL & CM_CTL_ENAB) { | ||
clockmgr_set_ctl(clk, (clk->CTL & ~CM_CTL_ENAB)); | ||
while(clk->CTL & CM_CTL_BUSY) {}; | ||
} | ||
} | ||
|
||
void clockmgr_config_ctl(clockmgr_t *clk, int32_t flags) { | ||
clockmgr_pause(clk); | ||
clk->CTL = CM_PASSWORD | flags; | ||
} | ||
|
||
void clockmgr_config_div(clockmgr_t *clk, int32_t divi, int32_t divf) { | ||
uint32_t save = clk->CTL; | ||
clockmgr_pause(clk); | ||
clockmgr_set_div(clk, divi, divf); | ||
if (save & CM_CTL_ENAB) { | ||
clockmgr_set_ctl(clk, save); | ||
} | ||
} |
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,53 @@ | ||
#ifndef MICROPY_INCLUDED_RPI_BCM283X_CLOCKMGR_H | ||
#define MICROPY_INCLUDED_RPI_BCM283X_CLOCKMGR_H | ||
|
||
#define CM_GP0 (IO_BASE + 0x101070) | ||
#define CM_GP1 (IO_BASE + 0x101078) | ||
#define CM_GP2 (IO_BASE + 0x101080) | ||
#define CM_PCM (IO_BASE + 0x101098) | ||
#define CM_PWM (IO_BASE + 0x1010a0) | ||
|
||
typedef volatile struct _clockmgr_t { | ||
uint32_t CTL; | ||
uint32_t DIV; | ||
} clockmgr_t; | ||
|
||
|
||
#define CM_PASSWORD (0x5a000000) | ||
|
||
#define CM_CTL_MASH_MASK (3U<<9) | ||
#define CM_CTL_MASH_IDIV (0U<<9) | ||
#define CM_CTL_MASH_1STG (1U<<9) | ||
#define CM_CTL_MASH_2STG (2U<<9) | ||
#define CM_CTL_MASH_3STG (3U<<9) | ||
|
||
#define CM_CTL_FLIP (1U<<8) | ||
#define CM_CTL_BUSY (1U<<7) | ||
#define CM_CTL_KILL (1U<<5) | ||
#define CM_CTL_ENAB (1U<<4) | ||
|
||
#define CM_CTL_SRC_MASK (0xfU) | ||
#define CM_CTL_SRC_GND (0U) | ||
#define CM_CTL_SRC_OSC (1U) | ||
#define CM_CTL_SRC_PLLA (4U) | ||
#define CM_CTL_SRC_PLLC (5U) | ||
#define CM_CTL_SRC_PLLD (6U) | ||
#define CM_CTL_SRC_HDMI (7U) | ||
|
||
#define CM_DIV_MASK (0x00ffffffU) | ||
|
||
__attribute__(( always_inline )) inline void clockmgr_set_ctl(clockmgr_t *clk, uint32_t ctl) { | ||
clk->CTL = CM_PASSWORD | (ctl & 0xffffff); | ||
} | ||
|
||
__attribute__(( always_inline )) inline void clockmgr_set_div(clockmgr_t *clk, uint32_t divi, uint32_t divf) { | ||
clk->DIV = CM_PASSWORD | (divi & 0xfff) << 12 | (divf & 0xfff); | ||
} | ||
|
||
void clockmgr_pause(clockmgr_t *clk); | ||
|
||
void clockmgr_config_ctl(clockmgr_t *clk, int32_t flags); | ||
|
||
void clockmgr_config_div(clockmgr_t *clk, int32_t divi, int32_t divf); | ||
|
||
#endif // MICROPY_INCLUDED_RPI_BCM283X_CLOCKMGR_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#ifndef MICROPY_INCLUDED_RPI_BCM283X_PWM_H | ||
#define MICROPY_INCLUDED_RPI_BCM283X_PWM_H | ||
|
||
#include "bcm283x.h" | ||
|
||
#define PWM (IO_BASE + 0x20C000) | ||
|
||
typedef volatile struct _pwm_t { | ||
uint32_t CTL; | ||
uint32_t STA; | ||
uint32_t DMAC; | ||
uint32_t undef1; | ||
uint32_t RNG1; | ||
uint32_t DAT1; | ||
uint32_t FIF1; | ||
uint32_t undef2; | ||
uint32_t RNG2; | ||
uint32_t DAT2; | ||
} pwm_t; | ||
|
||
#define CTL_MSEN2 (1<<15) | ||
#define CTL_USEF2 (1<<13) | ||
#define CTL_POLA2 (1<<12) | ||
#define CTL_SBIT2 (1<<11) | ||
#define CTL_RPTL2 (1<<10) | ||
#define CTL_MODE2 (1<<9) | ||
#define CTL_PWEN2 (1<<8) | ||
#define CTL_MSEN1 (1<<7) | ||
#define CTL_CLRF1 (1<<6) | ||
#define CTL_USEF1 (1<<5) | ||
#define CTL_POLA1 (1<<4) | ||
#define CTL_SBIT1 (1<<3) | ||
#define CTL_RPTL1 (1<<2) | ||
#define CTL_MODE1 (1<<1) | ||
#define CTL_PWEN1 (1) | ||
|
||
#define STA_STA4 (1<<12) | ||
#define STA_STA3 (1<<11) | ||
#define STA_STA2 (1<<10) | ||
#define STA_STA1 (1<<9) | ||
#define STA_BERR (1<<8) | ||
#define STA_GAPO4 (1<<7) | ||
#define STA_GAPO3 (1<<6) | ||
#define STA_GAPO2 (1<<5) | ||
#define STA_GAPO1 (1<<4) | ||
#define STA_RERR1 (1<<3) | ||
#define STA_WERR1 (1<<2) | ||
#define STA_EMPT1 (1<<1) | ||
#define STA_FULL1 (1) | ||
|
||
#define DMAC_ENAB (1<<31) | ||
#define DMAC_PANIC (255<<8) | ||
#define DMAC_DREQ (255) | ||
|
||
#endif // MICROPY_INCLUDED_RPI_BCM283X_PWM_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
copy these files to the root of your SD card. | ||
|
||
uncomment lines in main.py to use HDMI display as console screen. | ||
|
||
more info: https://github.com/boochow/micropython-raspberrypi |
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 @@ | ||
# exec(open("./lib/ramdisk.py").read()) |
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,13 @@ | ||
import gpu | ||
import framebuf | ||
|
||
class RPiScreen(framebuf.FrameBuffer): | ||
def __init__(self, width, height): | ||
self.width = width | ||
self.height = height | ||
gpu.fb_init(width,height,screen_w=1920,screen_h=1080) | ||
super().__init__(gpu.fb_data(),width,height,framebuf.RGB565) | ||
self | ||
|
||
def show(self): | ||
pass |
Oops, something went wrong.