![Lattice Semiconductor LatticeMico32 Скачать руководство пользователя страница 103](http://html1.mh-extra.com/html/lattice-semiconductor/latticemico32/latticemico32_hardware-developer-user-manual_3843852103.webp)
C
REATING
C
USTOM
C
OMPONENTS
IN
L
ATTICE
M
ICO
S
YSTEM
:
Custom Component Example
LatticeMico32 Hardware Developer User Guide
97
Software Source Files
Reg_Comp.c File
The Reg_Comp.c file, shown in Figure 48, implements
the software driver for the custom component.
Reg_Comp.h File
The Reg_Comp.h file, shown in Figure 49, is the header
file for the software driver.
Figure 48: Reg_Comp.c File
#include "Reg_Comp.h"
/* device initialization function */
void init_reg_device( struct st_reg_device * ctx )
{
/* simply copy initialization data for reg_08
* provided in the context structure to register-00 */
REG_DEV_REGISTER(ctx->b_addr,0) =
ctx->reg_08_value;
return;
}
Figure 49: Reg_Comp.h File
#ifndef _REG_COMP_HEADER_FILE_
#define _REG_COMP_HEADER_FILE_
#include "DDStructs.h"
#ifdef __cplusplus
extern "C"{
#endif /* __cplusplus */
/* device initialization function */
void init_reg_device( struct st_reg_device * ctx );
/* macro for reading/writing registers */
#define REG_DEV_REGISTER(BASE,OFFSET) \
*((volatile unsigned int *)(BASE + OFFSET))
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif//_REG_COMP_HEADER_FILE_