SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
 
Loading...
Searching...
No Matches
inject_i2c_master_v2.h
Go to the documentation of this file.
1/*
2 © 2017 Intel Corporation
3
4 This software and the related documents are Intel copyrighted materials, and
5 your use of them is governed by the express license under which they were
6 provided to you ("License"). Unless the License provides otherwise, you may
7 not use, modify, copy, publish, distribute, disclose or transmit this software
8 or the related documents without Intel's prior written permission.
9
10 This software and the related documents are provided as is, with no express or
11 implied warranties, other than those that are expressly stated in the License.
12*/
13
14#ifndef SIMICS_SYSTEMC_INJECTION_EXTENSION_INJECT_I2C_MASTER_V2_H
15#define SIMICS_SYSTEMC_INJECTION_EXTENSION_INJECT_I2C_MASTER_V2_H
16
17
18
23
24#include <string>
25
26namespace simics {
27namespace systemc {
28namespace injection {
29namespace extension {
30
32template <typename TPAYLOAD>
33class InjectI2cMasterV2 : public InjectBase<TPAYLOAD> {
34 public:
35 ATTR_DICT_PARSER_NAMESPACE("i2c_master_v2.")
36
37 bool setValue(AttrDictParser *parser, const std::string &key,
38 attr_value_t *attr, TPAYLOAD *gp) override {
39 if (key == "acknowledge") {
41 if (!i2cAckValue(parser, &ack, key))
42 return false;
43
45 ->acknowledge(ack);
46 return true;
47 } else if (key == "read_response") {
48 uint8_t value = 0;
49 if (!parser->value(&value))
50 return false;
51
53 ->read_response(value);
54 return true;
55 }
56
57 return false;
58 }
60 std::string key) {
61 uint64_t ack = 0;
62 if (!parser->value(&ack))
63 return false;
64
65 if (ack != types::I2C_ack && ack != types::I2C_noack) {
66 parser->reportError("%s must be either I2C_ack or I2C_noack",
67 key.c_str());
68 return false;
69 }
70
71 *v = static_cast<types::i2c_ack_t>(ack);
72 return true;
73 }
74};
75
76} // namespace extension
77} // namespace injection
78} // namespace systemc
79} // namespace simics
80
81#endif
#define ATTR_DICT_PARSER_NAMESPACE(ns)
Definition: attr_dict_parser.h:32
Definition: attr_dict_parser.h:38
void reportError(const char *str,...)
bool value(T *v)
Definition: attr_dict_parser.h:64
Definition: inject_base.h:43
bool setValue(AttrDictParser *parser, const std::string &key, attr_value_t *attr, TPAYLOAD *gp) override
Definition: inject_i2c_master_v2.h:37
bool i2cAckValue(AttrDictParser *parser, simics::types::i2c_ack_t *v, std::string key)
Definition: inject_i2c_master_v2.h:59
i2c_ack_t
Definition: i2c_ack.h:20
@ I2C_ack
Definition: i2c_ack.h:21
@ I2C_noack
Definition: i2c_ack.h:22
Definition: adapter.h:79