summaryrefslogtreecommitdiffstats
path: root/libs/NVRam
diff options
context:
space:
mode:
authorEvan Lojewski <github@meklort.com>2019-12-28 20:28:56 -0700
committerGitHub <noreply@github.com>2019-12-28 20:28:56 -0700
commitae757bb328dcc1eb6bbc703ac0606013f4e729da (patch)
tree7b1ac8860a50266eeb129546fbc2498396c333d7 /libs/NVRam
parente0912558b571ce29e2d48cf2c9d7b97ded57ac42 (diff)
downloadbcm5719-ortega-ae757bb328dcc1eb6bbc703ac0606013f4e729da.tar.gz
bcm5719-ortega-ae757bb328dcc1eb6bbc703ac0606013f4e729da.zip
stage1: Enable spi printouts when running from the RX CPU. (#9)
- Also fix an issue with the linker script that could cause bss initialization to be misaligned.
Diffstat (limited to 'libs/NVRam')
-rw-r--r--libs/NVRam/EM100.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/libs/NVRam/EM100.c b/libs/NVRam/EM100.c
index 939efac..c8382b3 100644
--- a/libs/NVRam/EM100.c
+++ b/libs/NVRam/EM100.c
@@ -102,10 +102,14 @@ void NVRAM_EM100_send_byte(uint8_t byte)
NVM.Write.r32 = nvm_write.r32;
}
-void NVRam_EM100_writeBytes(uint8_t bytes[], size_t num_bytes)
+bool NVRam_EM100_writeBytes(uint8_t bytes[], size_t num_bytes)
{
// Aquire the lock
- NVRam_acquireLock();
+ if(!NVRam_acquireLock())
+ {
+ // Unable to lock.
+ return false;
+ }
NVRam_enable();
// Save defaults and set sane values
@@ -139,6 +143,8 @@ void NVRam_EM100_writeBytes(uint8_t bytes[], size_t num_bytes)
NVRam_disable();
NVRam_releaseLock();
+
+ return true;
}
void NVRam_EM100_putchar(char c)
@@ -154,9 +160,19 @@ void NVRam_EM100_putchar(char c)
#if ENABLE_CONSOLE
NVRam_EM100_enableConsole();
#endif
- NVRam_EM100_writeBytes(gEM100Packet, EM100_PACKET_BUFFER_OFFSET + used_buffer);
- // Mark buffer as empty
- gEM100Packet[EM100_PACKET_MSG_LEN] = 0;
+ if(NVRam_EM100_writeBytes(gEM100Packet, EM100_PACKET_BUFFER_OFFSET + used_buffer))
+ {
+ // Mark buffer as empty
+ gEM100Packet[EM100_PACKET_MSG_LEN] = 0;
+ }
+ else
+ {
+ if(used_buffer >= EM100_MAX_BUFFER_LEN)
+ {
+ // Don't output any more chars
+ gEM100Packet[EM100_PACKET_MSG_LEN] = used_buffer - 1;;
+ }
+ }
#if ENABLE_CONSOLE
NVRam_EM100_disableConsole();
#endif
OpenPOWER on IntegriCloud