Skip to content

Commit

Permalink
Merge pull request #2 from gicking/output_via_function
Browse files Browse the repository at this point in the history
Output via function
  • Loading branch information
MarkStokes71 authored Oct 23, 2020
2 parents 56c8e63 + 3173c90 commit 2d177ee
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 11 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ stm8gal
*.x86_64
*.hex

# MSVC output
MSVC/x64/*
MSVC/Debug/*
MSVC/Release/*
*.opensdf
*.sdf
*.suo

# Doxygen output
doxygen/html/*
doxygen/latex/*
Expand Down
8 changes: 4 additions & 4 deletions MSVC/stm8gal.vcxproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
Expand Down Expand Up @@ -48,7 +48,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
Expand All @@ -61,13 +61,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
9 changes: 9 additions & 0 deletions bootloader.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
#ifndef _BOOTLOADER_H_
#define _BOOTLOADER_H_

#ifdef __cplusplus
extern "C"
{
#endif


// include files
#include "serial_comm.h"
Expand Down Expand Up @@ -93,6 +98,10 @@ STM8gal_Bootloader_errors_t bsl_memVerify(HANDLE ptrPort, uint8_t physInterface,
/// jump to flash or RAM
STM8gal_Bootloader_errors_t bsl_jumpTo(HANDLE ptrPort, uint8_t physInterface, uint8_t uartMode, uint64_t addr, uint8_t verbose);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // _BOOTLOADER_H_

// end of file
8 changes: 8 additions & 0 deletions console.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
#ifndef _CONSOLE_H_
#define _CONSOLE_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include <stdbool.h>

// color codes
Expand Down Expand Up @@ -99,6 +104,9 @@ int Error(char *format, ...);
/// terminate program after cleaning up
void Exit(uint8_t code, uint8_t pause);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // _CONSOLE_H_

Expand Down
9 changes: 9 additions & 0 deletions hexfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
#ifndef _HEXFILE_H_
#define _HEXFILE_H_

#ifdef __cplusplus
extern "C"
{
#endif

// include files
#include <stdint.h>

Expand Down Expand Up @@ -77,4 +82,8 @@ void export_txt(char *filename, uint16_t *imageBuf, uint8_t verbose);
/// export RAM image to binary file (w/o address)
void export_bin(char *filename, uint16_t *imageBuf, uint8_t verbose);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // _HEXFILE_H_
12 changes: 7 additions & 5 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ int main(int argc, char ** argv) {
char portname[STRLEN]=""; // name of communication port
HANDLE ptrPort = 0; // handle to communication port
int baudrate; // communication baudrate [Baud]
int uartMode; // UART bootloader mode: 0=duplex, 1=1-wire, 2=2-wire reply, other=auto-detect
uint8_t uartMode; // UART bootloader mode: 0=duplex, 1=1-wire, 2=2-wire reply, other=auto-detect
int resetSTM8; // reset STM8: 0=skip, 1=manual, 2=DTR line (RS232), 3=send 'Re5eT!' @ 115.2kBaud, 4=Arduino pin 8, 5=Raspi pin 12, 6=RTS line (RS232) (default: manual)
uint16_t *imageBuf; // global RAM image buffer (high byte != 0 indicates value is set)
bool verifyUpload; // verify memory after upload
Expand Down Expand Up @@ -508,9 +508,10 @@ int main(int argc, char ** argv) {

// read back after writing doesn't work for SPI (don't know why)
#if defined(USE_SPIDEV)
if ((physInterface == SPI_ARDUINO) || (physInterface == SPI_SPIDEV))
if (physInterface == SPI_SPIDEV)
verifyUpload = false;
#elif defined(USE_SPI_ARDUINO)
#endif
#if defined(USE_SPI_ARDUINO)
if (physInterface == SPI_ARDUINO)
verifyUpload = false;
#endif
Expand Down Expand Up @@ -1187,9 +1188,10 @@ int main(int argc, char ** argv) {

// don't know why, but seems to be required for SPI
#if defined(USE_SPIDEV)
if ((physInterface==SPI_SPIDEV) || (physInterface==SPI_ARDUINO))
if (physInterface==SPI_SPIDEV)
SLEEP(500);
#elif defined(USE_SPI_ARDUINO)
#endif
#if defined(USE_SPI_ARDUINO)
if (physInterface==SPI_ARDUINO)
SLEEP(500);
#endif
Expand Down
9 changes: 9 additions & 0 deletions main.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
#ifndef _MAIN_H_
#define _MAIN_H_

#ifdef __cplusplus
extern "C"
{
#endif


/*******
global includes
Expand Down Expand Up @@ -61,6 +66,10 @@ typedef enum {MUTE=0, SILENT, INFORM, CHATTY} verbose_t;
typedef enum {UART=0} physInterface_t;
#endif

#ifdef __cplusplus
} // extern "C"
#endif

#endif // _MAIN_H_

// end of file
2 changes: 1 addition & 1 deletion serial_comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void list_ports(void) {
);
if (fpCom != INVALID_HANDLE_VALUE) {
if (j!=1)
console_print(STDOUT, ", ");
console_print(STDOUT, ", ");
console_print(STDOUT, "COM%d", i);
CloseHandle(fpCom);
j++;
Expand Down
8 changes: 8 additions & 0 deletions serial_comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#ifndef _SERIAL_COMM_H_
#define _SERIAL_COMM_H_

#ifdef __cplusplus
extern "C"
{
#endif

// generic ANSI
#include <stdio.h>
Expand Down Expand Up @@ -88,6 +92,10 @@ uint32_t receive_port(HANDLE fpCom, uint8_t uartMode, uint32_t lenRx, char *R
/// flush port buffers
void flush_port(HANDLE fpCom);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // _SERIAL_COMM_H_

// end of file
9 changes: 9 additions & 0 deletions spi_Arduino_comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
#ifndef _SPI_ARDUINO_COMM_H_
#define _SPI_ARDUINO_COMM_H_

#ifdef __cplusplus
extern "C"
{
#endif

// includes
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -56,6 +61,10 @@ void setPin_Arduino(HANDLE fp, uint8_t pin, uint8_t state);
/// send/receive SPI frames via Arduino USB<->SPI bridge
uint32_t sendReceiveSPI_Arduino(HANDLE fp, uint8_t pin, uint32_t lenFrame, char *bufTx, char *bufRx);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // _SPI_ARDUINO_COMM_H_

// end of file
8 changes: 8 additions & 0 deletions spi_spidev_comm.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#ifndef _SPI_SPIDEV_COMM_H_
#define _SPI_SPIDEV_COMM_H_

#ifdef __cplusplus
extern "C"
{
#endif

// generic ANSI
#include <stdio.h>
Expand Down Expand Up @@ -65,6 +69,10 @@
void spi_transfer(HANDLE fp, int len, uint8_t *Tx, uint8_t *Rx);

#endif // USE_SPIDEV

#ifdef __cplusplus
} // extern "C"
#endif

#endif // _SPI_SPIDEV_COMM_H_

Expand Down
8 changes: 8 additions & 0 deletions timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#ifndef _TIMER_H_
#define _TIMER_H_

#ifdef __cplusplus
extern "C"
{
#endif

// include files
#include <stdint.h>
Expand All @@ -40,6 +44,10 @@ uint64_t millis(void);
/// get microseconds since start of program (as Arduino)
uint64_t micros(void);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // _TIMER_H_

// end of file
8 changes: 7 additions & 1 deletion version.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define _SW_VERSION_H_

/// 16b SW version identifier
#define VERSION ((1<<14) | (4<<6) | (0<<1) | 1) // -> v1.4.0
#define VERSION ((1<<14) | (4<<6) | (1<<1) | 1) // -> v1.4.1

#endif // _SW_VERSION_H_

Expand All @@ -29,6 +29,12 @@
Revision History
----------------
v1.4.1 (2020-10-15)
- split output in seperate function for GUI support
- improvements by Mark Stokes to simplify re-use as library (https://github.com/gicking/stm8gal/pull/16)
----------------
v1.4.0 (2020-04-09)
- improved S19 export for >16bit addresses
- added IHX export option
Expand Down

0 comments on commit 2d177ee

Please sign in to comment.