forked from dangiu/PicoMemcard
-
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.
Code refractoring, bugfixing and new features:
- update .gitignore - update psxPSI code - changed simulation to state maching based (following darren approach) - add missing NULL checks in memory_card.c - changed allocation of memory card in RAM memory - add global config.h file - led now reflects sync status (ram and flash memory card) - change auto sync delay to 5 seconds - change MSC ram disk export to automatic (no need for safe removal) Compilation requires fix for pico-sdk not yet merged: raspberrypi/pico-sdk#936
- Loading branch information
Showing
14 changed files
with
483 additions
and
363 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 was deleted.
Oops, something went wrong.
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,32 @@ | ||
#ifndef __CONFIG_H__ | ||
#define __CONFIG_H__ | ||
|
||
/* Global configuration options for PicoMemcard */ | ||
#define TUD_MOUNT_TIMEOUT 3000 // max time (in ms) before giving up on MSC mode (USB) and starting memcard simulation | ||
#define MSC_WRITE_SYNC_TIMEOUT 1 * 1000 // time (in ms) expired since last MSC write before exporting RAM disk into LFS | ||
#define IDLE_AUTOSYNC_TIMEOUT 5 * 1000 // time (in ms) the memory card must be inactive before automatic sync from RAM to LFS | ||
#define MEMCARD_FILE_NAME "memcard.mcr" // name of memory card file image | ||
|
||
/* Board targeted by build */ | ||
#define TARGET_PICO | ||
//#define TARGET_RP2040ZERO | ||
|
||
|
||
/* PSX Interface Pinout */ | ||
#ifdef TARGET_PICO | ||
#define PIN_DAT 5 | ||
#define PIN_CMD PIN_DAT + 1 // must be immediately after PIN_DAT | ||
#define PIN_SEL PIN_CMD + 1 // must be immediately after PIN_CMD | ||
#define PIN_CLK PIN_SEL + 1 // must be immediately after PIN_SEL | ||
#define PIN_ACK 9 | ||
#endif | ||
|
||
#ifdef TARGET_RP2040ZERO | ||
#define PIN_DAT 9 | ||
#define PIN_CMD PIN_DAT + 1 // must be immediately after PIN_DAT | ||
#define PIN_SEL PIN_CMD + 1 // must be immediately after PIN_CMD | ||
#define PIN_CLK PIN_SEL + 1 // must be immediately after PIN_SEL | ||
#define PIN_ACK 13 | ||
#endif | ||
|
||
#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,12 @@ | ||
#ifndef __LED_H__ | ||
#define __LED_H__ | ||
|
||
#include "pico/stdlib.h" | ||
|
||
void led_output_sync_status(bool out_of_sync); | ||
void blink(int amount, int on_ms, int off_ms); | ||
void blink_fast(int amount); | ||
void blink_normal(int amount); | ||
void blink_slow(int amount); | ||
|
||
#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
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,40 @@ | ||
#include "led.h" | ||
#include "hardware/gpio.h" | ||
|
||
#define LED_PIN 25 | ||
|
||
void led_output_sync_status(bool out_of_sync) { | ||
gpio_put(LED_PIN, !out_of_sync); | ||
} | ||
|
||
void blink(int amount, int on_ms, int off_ms) { | ||
bool initial_state = gpio_get(LED_PIN); | ||
if(initial_state) { | ||
/* turn led off if already on */ | ||
gpio_put(LED_PIN, false); | ||
sleep_ms(off_ms); | ||
--amount; // last blink is performed while restoring led state | ||
} | ||
for(int i = 0; i < amount; ++i) { | ||
gpio_put(LED_PIN, true); | ||
sleep_ms(on_ms); | ||
gpio_put(LED_PIN, false); | ||
sleep_ms(off_ms); | ||
} | ||
if(initial_state) { | ||
/* restore led state */ | ||
gpio_put(LED_PIN, true); | ||
} | ||
} | ||
|
||
void blink_fast(int amount) { | ||
blink(amount, 250, 250); | ||
} | ||
|
||
void blink_normal(int amount) { | ||
blink(amount, 500, 500); | ||
} | ||
|
||
void blink_slow(int amount) { | ||
blink(amount, 1000, 1000); | ||
} |
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.