Page MenuHomec4science

instruction.h
No OneTemporary

File Metadata

Created
Wed, Mar 5, 03:14

instruction.h

/*
File: instruction.h
Author: tuleu
Created on May 22, 2012, 4:53 PM
*/
#ifndef SBCP_UC_INSTRUCTION_H_
#define SBCP_UC_INSTRUCTION_H_
#include "sbcp-uc_config.h"
#include "common.h"
#include "sbcp_common.h"
/**
* \defgroup sbcp_instruction_m SBCP instruction module
*
* \brief Module to define SBCP instruction
*
* A SBCP device could have multiple instruction there is some standard one :
* - SBCP_INST_GET_FIRMWARE : send back the device firmware
* - SBCP_INST_GET_REGISTERS : send back a list of \ref sbcp_register_m
* - SBCP_INS_SET_REGISTERS : sets a list of \ref sbcp_register_m
*
*
* Moreover you can define your own instructions using sbcp_add_instruction(). It
* uses an sbcp_instruction_callback , so you can define what function will be called
* when the instuction will be processed.
*
* \warning : during an sbcp_instruction_callback user are intended to sets the
* response packet throught \ref sbcp_packet_m interface.
*
* \ingroup sbcp_m
*/
#if SBCP_INST_TABLE_SIZE >= 255
#error "Instruction table size should be < 255"
#endif
/**
* Type of an sbcp_instruction
* \ingroup sbcp_instruction_m
*/
typedef uint8_t sbcp_instruction;
/**
* Initialization instruction callback.
* User should define an initialization function that will create the device specific
* instructions through call to sbcp_add_instruction()
* \ingroup sbcp_instruction_m
*/
typedef void (*sbcp_init_device_instructions_fptr)();
/**
* Instruction callback. This a pointer to a function that will be called when
* the host sends an instruction.
* \param buffer the packet data that is sent
* \ingroup sbcp_instruction_m
*/
typedef void (*sbcp_instruction_callback)(unsigned int * buffer);
#define SBCP_NO_INSTRUCTION ((void*)0)
/**
* \internal
* @param init_device_specific
*/
void sbcp_init_instructions(sbcp_init_device_instructions_fptr init_device_specific);
/**
* Adds a device specific instruction
* \param instruction the instruction code value should be >= SBCP_INST_DEVICE_SPECIFIC_START
* \param callback the sbcp_instruction_callback that will be used.
* \ingroup sbcp_instruction_m
*/
void sbcp_add_instruction(sbcp_instruction instruction,
sbcp_instruction_callback callback);
void sbcp_get_firmware(unsigned int * buffer);
void sbcp_get_registers(unsigned int * buffer);
void sbcp_set_registers(unsigned int * buffer);
void sbcp_unlock_registers(unsigned int * buffer);
void sbcp_process_instruction(sbcp_instruction instruction,
unsigned int * buffer);
void sbcp_send_error_r_packet(sbcp_error error);
#endif // SBCP_INSTRUCTION_H_

Event Timeline