feat: add M95M02-only GAS and EEPROM profiles

Expose the existing registers through Modbus and service CAN using one GAS provider only in M95M02 builds.
Include the EEPROM layout/driver, LOAD protection and calibration, firmware identity and shared CCS build workflow.
Add transport/profile and SCI8 validation tests, documentation and the checked M95M02 firmware image.
This commit is contained in:
2026-10-09 16:17:37 +03:00
parent c6c9128238
commit 5d9818291b
63 changed files with 2307 additions and 365 deletions
+10
View File
@@ -6,3 +6,13 @@ void Setup_DAC_time(void);
/* Ñ÷¸ò÷èê ïóñêîâîãî èìïóëüñà è âûäåðæêè èíèöèàëèçàöèè äîñòóïíû ëîããåðó. */
extern unsigned long IMPowse, WAKEpowse;
extern unsigned int period_dac, time_dac;
/* Call once before IRQ; complete technological CAN packets update voltage. */
void Load_control_init(void);
void Load_voltage_can(unsigned int header, unsigned int a,
unsigned int b, unsigned int c);
/* 0x1300/8 words: signature, version, simulation, timeout, status, attempts,
* voltage, age. Only 0x1302 (simulation) and 0x1303 (timeout) are writable. */
unsigned int Load_protection_prepare(unsigned int function, unsigned int address,
unsigned int value, unsigned int *out, unsigned int *error);
+2 -2
View File
@@ -10,8 +10,8 @@
4876, 5005, 4876, 4847, 1898, 1873, 2535, 2502, // Áîðò 1
// ÓÌÏ UA UC IA IC 20mA O 4mA O 20mA I 4mA I
3820, 3790, 3505, 3380, 1736, 683, 854, 14, // Αξπς 0 1062 1980
3835, 3785, 3522, 3332, 1745, 689, 860, 17, // Αξπς 1 1720 2405
7580, 7540, 2310, 2420, 1736, 683, 854, 14, // Αξπς 0 1062 1980
7580, 7540, 2310, 2420, 1745, 689, 860, 17, // Αξπς 1 1720 2405
// ÁÊÑÑÄ 100 Ohm 150 Ohm
1281, 1272, 0, 0, 622, 2263, 0, 0,
+15
View File
@@ -0,0 +1,15 @@
#ifndef BALSAM167_EEPROM_CONFIG_H
#define BALSAM167_EEPROM_CONFIG_H
/* Build-time checkbox: 0 = AT25256B (32 KiB), 1 = M95M02-DR (256 KiB).
* This must match the soldered part BEFORE startup loads saved parameters.
* CCS: change the value below, then Project > Clean and Rebuild.
* Command-line builds may override EEPROM_M95M02 for that build only.
* A GUI checkbox cannot change SPI ROM boot or startup initialization.
*/
#ifndef EEPROM_M95M02
#define EEPROM_M95M02 0
#endif
#if EEPROM_M95M02 != 0 && EEPROM_M95M02 != 1
#error EEPROM_M95M02_must_be_0_or_1
#endif
#endif
+28
View File
@@ -0,0 +1,28 @@
#ifndef BALSAM167_GAS_H
#define BALSAM167_GAS_H
#include "eeprom_config.h"
#include <stdint.h>
/* Board profile 167/v1, word addresses, independent of the wire transport.
* The original register and UMP addresses remain valid in both builds.
* Only the physically fitted M95M02 version exposes the additional regions. */
#if EEPROM_M95M02
#define GAS167_REG_BASE 0x5000U
#define GAS167_REG_COUNT 128U
#define GAS167_INFO_BASE 0x5F00U
#define GAS167_INFO_WORDS 8U
#define GAS167_MAX_WORDS 124U
#define GAS167_PROFILE_VERSION 1U
#define GAS167_CAPABILITIES 7U /* bit 0 RTU, bit 1 service CAN, bit 2 FC06 */
/* Called by the main-loop transports under their snapshot IRQ lock.
* Capacity: at least GAS167_MAX_WORDS uint16_t words.
* RTU reads: 1..124 words; paired service CAN reads: 2..124, even.
* Successful reads return their count. Writes/errors return address/value.
* error uses Modbus codes 0 (success), 1 (function), 2 (address), 3 (value).
* No EEPROM I/O, allocation, or changes to the existing logger. */
int gas167_contains(uint16_t address);
unsigned gas167_prepare(unsigned function, uint16_t address, uint16_t value,
int can, uint16_t *reply, unsigned *error);
#endif
#endif
+5
View File
@@ -95,6 +95,11 @@
#define DAC_go modbus[0x50] // íà÷àëî çàðàäà
#define DAC_stop modbus[0x51] // êîíåö çàðàäà
/* LOAD-only persistent CAN timeout (ms), read-only status and attempts. */
#define LOAD_CAN_TIMEOUT modbus[0x52]
#define LOAD_STATUS modbus[0x7C]
#define LOAD_ATTEMPTS modbus[0x7D]
#define Cancount (modbus+0x60) // ïàóçà ìåæäó I ïîñûëêàìè CAN
#define Bright (modbus+0x62) // àðêîñòü ñèãíàëüíûõ ëàìïî÷åê
#define Brightness modbus[0x62] // àðêîñòü ñèãíàëüíûõ ëàìïî÷åê
+22 -9
View File
@@ -2,8 +2,19 @@
#define __SPISE2P_H__
/* Physical EEPROM layout shared with the linker and SETGUI. */
#include "eeprom_config.h"
#include "include/balsam167_eeprom_layout.h"
// ¨ìêîñòü ïàìàòè â áàéòàõ
#define SEEPROM_LEN 0x10000
/* Preserve compact 16-bit arithmetic for the original 32-KiB build.
* Only the large part needs 32-bit word addresses and transfer lengths. */
#if EEPROM_M95M02
typedef unsigned long SE2P_SIZE;
#else
typedef unsigned int SE2P_SIZE;
#endif
#define SEEPROM_LEN BALSAM167_EEPROM_BYTES
#define NULL 0
@@ -58,8 +69,10 @@ typedef struct {
/* Object declaration */
typedef struct {
SE2P_DATA *msgPtr;
unsigned int csr; /* control/status register */
/* Main loop publishes the descriptor before setting csr; Timer2 consumes it.
* Both accesses are volatile so optimization cannot publish the request first. */
SE2P_DATA * volatile msgPtr;
volatile unsigned int csr; /* control/status register */
void (*init)(void *);
void (*tick)(void *);
void (*csset)(void);
@@ -85,12 +98,12 @@ void spiSe2pWrite(SPISE2P_DRV *se2p, SE2P_DATA *data);
void spiSe2pRead(SPISE2P_DRV *se2p, SE2P_DATA *data);
#if(SPISE2P_DATA_WIDTH==SIXTEEN_BIT)
#define PROM_LEN 0x8000
#define PAGE_LEN 0x20
#define PROM_LEN BALSAM167_EEPROM_WORDS
#define PAGE_LEN (BALSAM167_EEPROM_PAGE_BYTES / 2)
#define WORD_LEN 2
#else
#define PROM_LEN 0x4000
#define PAGE_LEN 0x40
#define PROM_LEN BALSAM167_EEPROM_BYTES
#define PAGE_LEN BALSAM167_EEPROM_PAGE_BYTES
#define WORD_LEN 1
#endif
@@ -105,7 +118,7 @@ void InitSeeprom(void);
** adres = 0..0x4000, åñëè äëèíà ñëîâà 16 áèò **
** buf - óêàçàòåëü íà ïàìàòü, îòêóäà ïèñàòü. **
** size - äëèíà áëîêà â áàéòàõ. Ïî-ëþáîìó â áàéòàõ! */
void Seeprom_write(unsigned int adres, unsigned int buf[], unsigned int size);
void Seeprom_write(SE2P_SIZE adres, unsigned int buf[], SE2P_SIZE size);
/* ×òåíèå áëîêà èç SEEPROM. Ïàðàìåòðû òàêîâû: **
** adres - àäðåñ â åïðîìêå, îòêóäà ÷èòàòü. **
@@ -113,7 +126,7 @@ void Seeprom_write(unsigned int adres, unsigned int buf[], unsigned int size);
** adres = 0..0x4000, åñëè äëèíà ñëîâà 16 áèò **
** buf - óêàçàòåëü íà ïàìàòü, êóäà ÷èòàòü. **
** size - äëèíà áëîêà â áàéòàõ. Ïî-ëþáîìó â áàéòàõ! */
void Seeprom_read(unsigned int adres, unsigned int buf[], unsigned int size);
void Seeprom_read(SE2P_SIZE adres, unsigned int buf[], SE2P_SIZE size);
#endif