Select Git revision
dbrepo-1.6.2-py3-none-any.whl
smile_fee_cmd.c 27.61 KiB
/**
* @file fee_cmd.c
* @author Armin Luntzer (armin.luntzer@univie.ac.at),
* @date 2018
*
* @copyright GPLv2
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* @brief SMILE FEE RMAP command library
* @see SMILE FEE to DPU Interface Requirements Document MSSL-SMILE-SXI-IRD-0001
*
* @note I realise that the actual register accessors are somewhat redundant
* since they only reference the registers by a numeric id and could be
* converted into a single function in principle. This file is however
* an adaptation from code for the PLATO RDUC, so this was the easiest
* approach, as I might create a more generic lower/intermediate
* (i.e. rmap command generation and transaction control) library,
* since the methods used here and for PLATO are IMO the smartest way
* to approach remote instrument RMAP control. This does however require
* a specific call interface, where I don't want va_args, so I can't just
* add another parameter.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <rmap.h>
#include <smile_fee_cmd.h>
#include <smile_fee_rmap.h>
/**
* @brief generate a read command for an arbitrary register (internal)
*
* @param trans_id a transaction identifier
*
* @param cmd the command buffer; if NULL, the function returns the needed size
*
* @param addr the register address
*
* @note this will configure a multi-address, 4 byte wide read command, because
* the IWF RMAP core does not support single address read commands
*/
static int fee_read_cmd_register_internal(uint16_t trans_id, uint8_t *cmd,
uint32_t addr)
{
return smile_fee_gen_cmd(trans_id, cmd, RMAP_READ_ADDR_INC, addr, 4);
}
/**
* @brief generate a write command for an arbitrary register (internal)
*
* @param trans_id a transaction identifier
*
* @param cmd the command buffer; if NULL, the function returns the needed size
*
* @param addr the register address
*
* @returns the size of the command data buffer or 0 on error