1 // Copyright 2021 The Pigweed Authors
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
7 // https://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
15 #include "pw_assert/assert.h"
16 #include "pw_bloat/bloat_this_binary.h"
17 #include "pw_log/log.h"
18 #include "pw_sys_io/sys_io.h"
23 static constexpr uint32_t kMagic = 0x8badf00d;
25 constexpr BasicPacket(uint32_t addr, uint64_t data)
26 : magic(kMagic), address(addr), payload(data) {}
36 pw::bloat::BloatThisBinary();
38 // Ensure we are paying the cost for log and assert.
39 BasicPacket packet(0x1, 0x2);
40 PW_CHECK_UINT_EQ(packet.magic, BasicPacket::kMagic, "Some CHECK logic");
41 PW_LOG_INFO("Packet has address %u", static_cast<unsigned>(packet.address));
42 PW_LOG_INFO("pw_StatusString %s", pw::OkStatus().str());
44 std::array<std::byte, sizeof(BasicPacket)> packet_buffer;
45 pw::sys_io::ReadBytes(packet_buffer);
46 pw::sys_io::WriteBytes(packet_buffer);
48 return static_cast<int>(packet.payload);