Skip to content

Commit

Permalink
update to latest Meatloaf code
Browse files Browse the repository at this point in the history
add serial console shell
add display task for RGB LED STRIP/LCD support
  • Loading branch information
idolpx committed Feb 8, 2025
1 parent 625dbb7 commit a6c4203
Show file tree
Hide file tree
Showing 160 changed files with 17,814 additions and 6,290 deletions.
2 changes: 1 addition & 1 deletion components/libsmb2/examples/smb2-stat-sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int main(int argc, char *argv[])
t = (time_t)st.smb2_ctime;
printf("Ctime:%s", asctime(localtime(&t)));
t = (time_t)st.smb2_btime;
printf("Btime:%s", asctime(localtime(&t)));
printf("Btime:%s", asctime(localtime(&t)));

smb2_disconnect_share(smb2);
smb2_destroy_url(url);
Expand Down
6 changes: 1 addition & 5 deletions include/cbm_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ typedef enum
#define TIMING_Tna 32 // Extra delay before first bit is sent
#define TIMEOUT_Tne 250

#define TIMING_Ts 70 // BIT SET-UP TALKER 71us 20us 70us -
#define TIMING_Ts 80 // BIT SET-UP TALKER 71us 20us 70us -
#define TIMING_Ts0 40 // BIT SET-UP LISTENER PRE 57us 47us
#define TIMING_Ts1 30 // BIT SET-UP LISTENER POST 18us 24us
#define TIMING_Tv 20 // DATA VALID VIC20 76us 26us 20us 20us - (Tv and Tpr minimum must be 60μ s for external device to be a talker. )
Expand Down Expand Up @@ -204,14 +204,10 @@ typedef enum
// Not Inverted
#define IEC_ASSERTED true
#define IEC_RELEASED false
#define LOW 0x00
#define HIGH 0x01
#else
// Inverted
#define IEC_ASSERTED false
#define IEC_RELEASED true
#define LOW 0x01
#define HIGH 0x00
#endif

#endif // CBMDEFINES_H
9 changes: 5 additions & 4 deletions include/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
#include "../lib/hardware/fnUART.h"
#define Serial fnUartDebug

#define Debug_print(...) fnUartDebug.print( __VA_ARGS__ )
#define Debug_printf(...) fnUartDebug.printf( __VA_ARGS__ )
#define Debug_println(...) fnUartDebug.println( __VA_ARGS__ )
#define Debug_printv(format, ...) {fnUartDebug.printf( ANSI_YELLOW "[%s:%u] %s(): " ANSI_GREEN_BOLD format ANSI_RESET "\r\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);}
#define Debug_print(...) printf( __VA_ARGS__ )
#define Debug_printf(format, ...) { printf( format, ##__VA_ARGS__ ); }
#define Debug_println(...) { printf( __VA_ARGS__ ); printf( "\r\n" ); }
#define Debug_printv(format, ...) { printf( ANSI_YELLOW "[%s:%d] %s(): " ANSI_GREEN_BOLD format ANSI_RESET "\r\n", __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__);}

#define HEAP_CHECK(x) Debug_printf("HEAP CHECK %s " x "\r\n", heap_caps_check_integrity_all(true) ? "PASSED":"FAILED")
#define DEBUG_MEM_LEAK {Debug_printv("Heap[%lu] Low[%lu] Task[%u]", esp_get_free_heap_size(), esp_get_free_internal_heap_size(), uxTaskGetStackHighWaterMark(NULL));}
#else
// Use util_debug_printf() helper function
#include <utils.h>
Expand Down
99 changes: 99 additions & 0 deletions include/esp-idf-arduino.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// -----------------------------------------------------------------------------
// Copyright (C) 2024 David Hansel
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have receikved a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
// -----------------------------------------------------------------------------

#ifndef IECESPIDF_H
#define IECESPIDF_H

#include <stdint.h>
#include <memory.h>
#include <esp_timer.h>
#include <driver/gpio.h>
#include <soc/gpio_reg.h>
#include "hal/gpio_hal.h"
#include <freertos/FreeRTOS.h>

#define ARDUINO 2024
#define ESP32

#define PROGMEM

#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#pragma GCC diagnostic ignored "-Wvolatile"

typedef void (*interruptFcn)(void *);

#define INPUT 0x0
#define OUTPUT 0x1
#define INPUT_PULLUP 0x2
#define LOW 0x0
#define HIGH 0x1
#define FALLING GPIO_INTR_NEGEDGE
#define RISING GPIO_INTR_POSEDGE
#define bit(n) (1<<(n))
#define digitalWrite(pin, v) gpio_set_level((gpio_num_t) pin, v);
#define pinMode(pin, mode) { gpio_reset_pin((gpio_num_t) pin); gpio_set_direction((gpio_num_t)pin, mode==OUTPUT ? GPIO_MODE_OUTPUT : GPIO_MODE_INPUT); if( mode==INPUT_PULLUP ) gpio_pullup_en((gpio_num_t) pin); }
#define digitalPinToGPIONumber(digitalPin) (digitalPin)
#define digitalPinToBitMask(pin) (1UL << (digitalPinToGPIONumber(pin)&31))
#define portInputRegister(port) ((volatile uint32_t*)((port)?GPIO_IN1_REG:GPIO_IN_REG))
#define portOutputRegister(port) ((volatile uint32_t*)((port)?GPIO_OUT1_REG:GPIO_OUT_REG))
#define portModeRegister(port) ((volatile uint32_t*)((port)?GPIO_ENABLE1_REG:GPIO_ENABLE_REG))
#define digitalPinToPort(pin) ((digitalPinToGPIONumber(pin)>31)?1:0)
#define digitalPinToInterrupt(p) ((((uint8_t)digitalPinToGPIONumber(p))<SOC_GPIO_PIN_COUNT)?digitalPinToGPIONumber(p):NOT_AN_INTERRUPT)

#define noInterrupts() portDISABLE_INTERRUPTS()
#define interrupts() portENABLE_INTERRUPTS()
#define micros() ((uint32_t) esp_timer_get_time())
#define PSTR(x) x
#define strncmp_P strncmp
#define strcmp_P strcmp
#define min(x, y) ((x)<(y) ? (x) : (y))
#define max(x, y) ((x)>(y) ? (x) : (y))

static void delayMicroseconds(uint32_t n)
{
uint32_t s = micros();
while((micros()-s)<n);
}

static void attachInterrupt(uint8_t pin, interruptFcn userFunc, gpio_int_type_t intr_type)
{
static bool interrupt_initialized = false;

if (pin >= SOC_GPIO_PIN_COUNT) return;

if (!interrupt_initialized) {
esp_err_t err = gpio_install_isr_service(0 /* ESP_INTR_FLAG_IRAM */);
interrupt_initialized = (err == ESP_OK) || (err == ESP_ERR_INVALID_STATE);
}

gpio_set_intr_type((gpio_num_t)pin, intr_type);
gpio_isr_handler_add((gpio_num_t)pin, userFunc, NULL);

gpio_hal_context_t gpiohal;
gpiohal.dev = GPIO_LL_GET_HW(GPIO_PORT_0);
gpio_hal_input_enable(&gpiohal, pin);
}

static void detachInterrupt(uint8_t pin)
{
gpio_isr_handler_remove((gpio_num_t)pin);
gpio_set_intr_type((gpio_num_t)pin, GPIO_INTR_DISABLE);
}

#endif
7 changes: 7 additions & 0 deletions include/pinmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
#include "pinmap/atari2600.h"


/* LED Strip NEW */
#define RGB_LED_DATA_PIN PIN_LED_RGB
#define RGB_LED_BRIGHTNESS 15 // max mA the LED can use determines brightness
#define RGB_LED_COUNT 5
#define RGB_LED_TYPE WS2812B
#define RGB_LED_ORDER GRB

#ifndef PIN_DEBUG
#define PIN_DEBUG PIN_IEC_SRQ
#endif
Expand Down
20 changes: 9 additions & 11 deletions include/pinmap/fujiloaf-rev0.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
#ifndef PINMAP_FUJILOAF_REV0_H
#define PINMAP_FUJILOAF_REV0_H

// https://www.espressif.com.cn/sites/default/files/documentation/esp32-wrover-e_esp32-wrover-ie_datasheet_en.pdf

#ifdef PINMAP_FUJILOAF_REV0

// ESP32-WROVER-E-N16R8
#define FLASH_SIZE 16
#define PSRAM_SIZE 8

/* SD Card */
#define PIN_CARD_DETECT GPIO_NUM_35 // fnSystem.h
#define PIN_CARD_DETECT_FIX GPIO_NUM_35 // fnSystem.h
Expand All @@ -29,20 +36,11 @@
#define PIN_LED_WIFI GPIO_NUM_2 // led.cpp
#define PIN_LED_BUS GPIO_NUM_12 // 4 FN
#define PIN_LED_BT GPIO_NUM_NC // No BT LED

/* LED Strip NEW */
#define LEDSTRIP_DATA_PIN GPIO_NUM_4
#define LEDSTRIP_COUNT 5
#define LEDSTRIP_BRIGHTNESS 15 // max mA the LED can use determines brightness
#define LEDSTRIP_TYPE WS2812B
#define LEDSTRIP_RGB_ORDER GRB
// LED order on the strip starting with 0
#define LEDSTRIP_WIFI_NUM 0
#define LEDSTRIP_BUS_NUM 4
#define LEDSTRIP_BT_NUM 2
#define PIN_LED_RGB GPIO_NUM_4

/* Audio Output */
#define PIN_DAC1 GPIO_NUM_25 // samlib.h
#define PIN_I2S GPIO_NUM_25

// Reset line is available
#define IEC_HAS_RESET
Expand Down
57 changes: 32 additions & 25 deletions include/pinmap/iec-nugget.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#ifndef PINMAP_IEC_NUGGET_H
#define PINMAP_IEC_NUGGET_H

// https://www.wemos.cc/en/latest/d32/d32_pro.html
// https://www.wemos.cc/en/latest/_static/files/sch_d32_pro_v2.0.0.pdf
// https://www.espressif.com.cn/sites/default/files/documentation/esp32-wrover-e_esp32-wrover-ie_datasheet_en.pdf

#ifdef PINMAP_IEC_NUGGET

// ESP32-WROVER-E-N16R8
#define FLASH_SIZE 16
#define PSRAM_SIZE 8

/* SD Card */
// pins 12-15 are used to interface with the JTAG debugger
// so leave them alone if we're using JTAG
#ifndef JTAG
#define PIN_CARD_DETECT GPIO_NUM_15 // fnSystem.h
#define PIN_CARD_DETECT GPIO_NUM_12 // fnSystem.h
#define PIN_CARD_DETECT_FIX GPIO_NUM_15 // fnSystem.h
#endif

#define PIN_SD_HOST_CS GPIO_NUM_4 // LOLIN D32 Pro
#define PIN_SD_HOST_MISO GPIO_NUM_19
Expand All @@ -21,39 +25,42 @@
#define PIN_UART0_TX GPIO_NUM_1
#define PIN_UART1_RX GPIO_NUM_9
#define PIN_UART1_TX GPIO_NUM_10
#define PIN_UART2_RX GPIO_NUM_33
#define PIN_UART2_TX GPIO_NUM_21
#define PIN_UART2_RX GPIO_NUM_NC
#define PIN_UART2_TX GPIO_NUM_NC

/* Buttons */
#define PIN_BUTTON_A GPIO_NUM_NC // keys.cpp
#define PIN_BUTTON_A GPIO_NUM_0 // keys.cpp
#define PIN_BUTTON_B GPIO_NUM_NC
#define PIN_BUTTON_C GPIO_NUM_NC

/* LEDs */
#define PIN_LED_WIFI GPIO_NUM_5 // led.cpp
#define PIN_LED_BUS GPIO_NUM_2 // 4 FN

// pins 12-15 are used to interface with the JTAG debugger
// so leave them alone if we're using JTAG
#ifndef JTAG
#define PIN_LED_WIFI GPIO_NUM_2 // led.cpp
#define PIN_LED_BUS GPIO_NUM_5
#define PIN_LED_BT GPIO_NUM_13
#else
#define PIN_LED_BT GPIO_NUM_5 // LOLIN D32 PRO
#endif
#define PIN_LED_RGB GPIO_NUM_13

/* Audio Output */
#define PIN_DAC1 GPIO_NUM_25 // samlib.h

/* Commodore IEC Pins */
//#define IEC_HAS_RESET // Reset line is available
// CLK & DATA lines in/out are split between two pins
//#define IEC_SPLIT_LINES

// Line values are inverted (7406 Hex Inverter Buffer)
//#define IEC_INVERTED_LINES

#define PIN_IEC_RESET GPIO_NUM_34
#define PIN_IEC_ATN GPIO_NUM_32
#define PIN_IEC_CLK_IN GPIO_NUM_33
#define PIN_IEC_CLK_OUT GPIO_NUM_33
#define PIN_IEC_DATA_IN GPIO_NUM_14
#define PIN_IEC_DATA_OUT GPIO_NUM_14
#define PIN_IEC_SRQ GPIO_NUM_27
// Reset line is available
#define IEC_HAS_RESET
// WIRING
// C64 DIN6 D32Pro TFT
#define PIN_IEC_ATN GPIO_NUM_32 // ATN 3 A T-LED 32 10 (PURPLE)
#define PIN_IEC_CLK_IN GPIO_NUM_33 // CLK 4 A T-RST 33 8 (BROWN)
#define PIN_IEC_CLK_OUT GPIO_NUM_33 //
#define PIN_IEC_DATA_IN GPIO_NUM_14 // DATA 5 T-CS 14 2 (BLACK)
#define PIN_IEC_DATA_OUT GPIO_NUM_14 //
#define PIN_IEC_SRQ GPIO_NUM_27 // SRQ 1 T-DC 27 7 (ORANGE)
#define PIN_IEC_RESET GPIO_NUM_34 // RESET 6 A 34 N/C
// GND 2 GND 9 (GREY)

/* Modem/Parallel Switch */
/* Unused with Nugget */
Expand Down
2 changes: 1 addition & 1 deletion lib/FileSystem/fnFileSMB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int FileHandlerSMB::seek(long int off, int whence)
Debug_printf("%s\n", smb2_get_error(_smb));
return -1;
}
Debug_printf("new pos is %lu\n", new_pos);
Debug_printf("new pos is %llu\n", new_pos);
return 0;
}

Expand Down
3 changes: 0 additions & 3 deletions lib/FileSystem/fnFsLittleFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,6 @@ bool FileSystemLittleFS::start()
Debug_printv(" partition size: %u, used: %u, free: %u\r\n", total, used, total-used);
*/
#endif

// Create SYSTEM DIR if it doesn't exist
//create_path( SYSTEM_DIR );
}

return _started;
Expand Down
3 changes: 0 additions & 3 deletions lib/FileSystem/fnFsSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,9 +685,6 @@ bool FileSystemSDFAT::start()
Debug_printf(" partition type: %s\r\n", partition_type());
Debug_printf(" partition size: %llu, used: %llu\r\n", total_bytes(), used_bytes());
*/

// Create SYSTEM DIR if it doesn't exist
//create_path( SYSTEM_DIR );
}
else
{
Expand Down
4 changes: 4 additions & 0 deletions lib/FileSystem/fnFsSMB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,13 @@ bool FileSystemSMB::dir_open(const char *path, const char *pattern, uint16_t di
fs_de->modified_time = (time_t)smb_de->st.smb2_mtime;

if (fs_de->isDir)
{
Debug_printf(" add entry: \"%s\"\tDIR\n", fs_de->filename);
}
else
{
Debug_printf(" add entry: \"%s\"\t%lu\n", fs_de->filename, fs_de->size);
}
}
smb2_closedir(_smb, smb_dir);
}
Expand Down
Loading

0 comments on commit a6c4203

Please sign in to comment.