forked from gicking/STM8_serial_flasher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootloader.h
executable file
·63 lines (44 loc) · 1.75 KB
/
bootloader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
\file bootloader.h
\author G. Icking-Konert
\date 2014-03-14
\version 0.1
\brief declaration of STM bootloader routines
declaration of of STM bootloader routines
*/
// for including file only once
#ifndef _BOOTLOADER_H_
#define _BOOTLOADER_H_
// include files
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "serial_comm.h"
// BSL command codes
#define GET 0x00 // gets version and commands supported by the BSL
#define READ 0x11 // read up to 256 bytes of memory
#define ERASE 0x43 // erase flash program memory/data EEPROM sectors
#define WRITE 0x31 // write up to 128 bytes to RAM or flash
#define GO 0x21 // jump to a specified address e.g. flash
// BSL return codes
#define SYNCH 0x7F // Synchronization byte
#define ACK 0x79 // Acknowledge
#define NACK 0x1F // No acknowledge
#define BUSY 0xAA // Busy flag status
/// synchronize to microcontroller BSL
uint8_t bsl_sync(HANDLE ptrPort);
/// get microcontroller type and BSL version
uint8_t bsl_getInfo(HANDLE ptrPort, int *flashsize, uint8_t *vers);
/// read from microcontroller memory
uint8_t bsl_memRead(HANDLE ptrPort, uint32_t addrStart, uint32_t numBytes, char *buf);
/// check if address exists
uint8_t bsl_memCheck(HANDLE ptrPort, uint32_t addr);
/// erase microcontroller flash sector
uint8_t bsl_flashErase(HANDLE ptrPort, uint32_t addr);
/// upload to microcontroller flash or RAM
uint8_t bsl_memWrite(HANDLE ptrPort, uint32_t addrStart, uint32_t numBytes, char *buf, uint8_t verbose);
/// jump to flash or RAM
uint8_t bsl_jumpTo(HANDLE ptrPort, uint32_t addr);
#endif // _BOOTLOADER_H_
// end of file