На стороне приложения
В Хидере
#ifndef __SIGTATURE_H__
#define __SIGTATURE_H__
#include <stdint.h>
/*******************************************************************************/
#ifndef STRINGIFY
#define STRINGIFY(x) #x
#endif
#define SIGNATURE_ADDRESS 0x08010000 /* Signature placement address */
#define PLACE_DATA_TO(ADDRESS) __attribute__((section (".ARM.__at_"STRINGIFY(ADDRESS))))
/*******************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
typedef struct signature_s
{
char vendor[16]; /* Equipment manufacturer (Rostselmash), char string */
char hw_model[32]; /* Equihment model (ie. DBK-10), char string */
char sw_build[16]; /* Build date (ie. Aug 12 2025), char string, created automatically */
uint32_t hw_revision; /* Board revision, numberic */
uint32_t sw_maijor; /* Software maijor version, numberic */
uint32_t sw_minor; /* Software minor version, numberic */
uint32_t sw_patch; /* Software patch version, numberic */
struct api_s
{
int (*open)(const char *device); /* Open device, ie. dsc=open("CAN"), return descriptor to device driver, numeric */
int (*read)(int drv_dsc,int channel,void *buff, int lenth); /* Read lenth bytes from device (drv_dsc,channel) to buff */
int (*write)(int drv_dsc,int channel,void *buff, int lenth); /* Write lenth bytes to device (drv_dsc,channel) from buff */
int (*ioctl)(int drv_dsc,int channel,int cmd, void *arg); /* Control device (drv_dsc,channel) */
int (*close)(int drv_dsc); /* Close (drv_dsc,channel) */
int (*errno)(void);
}api;
uint32_t start;
uint32_t end;
const uint32_t *crc;
}signature_t;
int api_open(const char *device);
int api_read(int drv_dsc,int channel,void *buff, int lenth);
int api_write(int drv_dsc,int channel,void *buff, int lenth);
int api_ioctl(int drv_dsc,int channel,int cmd, void *arg);
int api_close(int drv_dsc);
#ifdef __cplusplus
}
#endif
#endif /* __SIGTATURE_H__ */
В сишнике
#include "api.h"
const signature_t * const bsp = (signature_t*)SIGNATURE_ADDRESS;
int api_open(const char *device)
{
return bsp->api.open(device);
}
int api_read(int drv_dsc,int channel,void *buff, int lenth) /* Read lenth bytes from device (drv_dsc,channel) to buff */
{
return bsp->api.read(drv_dsc,channel,buff, lenth);
}
int api_write(int drv_dsc,int channel,void *buff, int lenth) /* Write lenth bytes to device (drv_dsc,channel) from buff */
{
return bsp->api.write(drv_dsc,channel,buff, lenth);
}
int api_ioctl(int drv_dsc,int channel,int cmd, void *arg) /* Control device (drv_dsc,channel) */
{
return bsp->api.ioctl(drv_dsc,channel,cmd, arg);
}
int api_close(int drv_dsc)
{
return bsp->api.close(drv_dsc);
}