Skip to content

Commit c4fb80b

Browse files
Roc: Fix GPIO_WRITE
1 parent 0ff4a1e commit c4fb80b

File tree

3 files changed

+37
-8
lines changed

3 files changed

+37
-8
lines changed

src/CommandLineUtilities/AliceLowlevelFrontend/AliceLowlevelFrontend.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,28 @@ class ScaWriteRpc: DimRpcInfoWrapper
224224

225225
std::string write(uint32_t command, uint32_t data)
226226
{
227-
auto string = std::to_string(command) + ',' + std::to_string(data);
227+
auto string = std::to_string(data) + ',' + std::to_string(command);
228228
setString(string);
229229
return stripPrefix(getString());
230230
}
231231
};
232232

233+
class ScaGpioWriteRpc: DimRpcInfoWrapper
234+
{
235+
public:
236+
ScaGpioWriteRpc(const std::string& serviceName)
237+
: DimRpcInfoWrapper(serviceName)
238+
{
239+
}
240+
241+
std::string write(uint32_t data)
242+
{
243+
setString(std::to_string(data));
244+
return stripPrefix(getString());
245+
}
246+
};
247+
248+
233249
class StringRpcServer: public DimRpc
234250
{
235251
public:

src/CommandLineUtilities/AliceLowlevelFrontend/ProgramAliceLowlevelFrontendClient.cxx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,31 @@ class ProgramAliceLowlevelFrontendClient: public Program
7171
Alf::RegisterWriteRpc writeRpc(names.registerWriteRpc());
7272
Alf::ScaReadRpc scaReadRpc(names.scaRead());
7373
Alf::ScaWriteRpc scaWriteRpc(names.scaWrite());
74+
Alf::ScaGpioWriteRpc scaGpioWriteRpc(names.scaGpioWrite());
7475
Alf::PublishRpc publishRpc(names.publishStartCommandRpc());
7576

7677
publishRpc.publish("ALF/TEST/1", 1.0, {0x1fc});
7778
publishRpc.publish("ALF/TEST/2", 3.0, {0x100, 0x104, 0x108});
7879

80+
for (int i = 0; i < 10; ++i) {
81+
cout << "SCA GPIO write" << endl;
82+
cout << " result: " << scaGpioWriteRpc.write(0x0f0f0f0f) << endl;
83+
}
84+
85+
// for (int i = 0; i < 10; ++i) {
86+
// auto transactionId = i + 0x10000;
87+
// cout << "SCA write" << endl;
88+
// cout << " result: " << scaWriteRpc.write(0xffff + transactionId, i) << endl;
89+
// cout << "SCA read" << endl;
90+
// cout << " result: " << scaReadRpc.read() << endl;
91+
// }
92+
7993
cout << "1k writes to 0x1fc..." << endl;
8094
for (int i = 0; i < 1000; ++i) {
8195
readRpc.readRegister(0x1fc);
8296
}
8397
cout << "Done!" << endl;
8498

85-
cout << "SCA read" << endl;
86-
cout << " result: " << scaReadRpc.read() << endl;
87-
cout << "SCA write" << endl;
88-
cout << " result: " << scaWriteRpc.write(0x0, 0x0) << endl;
89-
9099
while (!isSigInt())
91100
{
92101
cout << "-------------------------------------\n";

src/CommandLineUtilities/AliceLowlevelFrontend/Sca.cxx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,16 @@ void Sca::write(uint32_t command, uint32_t data)
6060
barWrite(Registers::WRITE_DATA, data);
6161
barWrite(Registers::WRITE_COMMAND, command);
6262
executeCommand();
63-
//auto time = barRead(Registers::TIME);
63+
auto time = barRead(Registers::TIME) * 4;
64+
// printf("Sca::write DATA=0x%x CH=0x%x TR=0x%x CMD=0x%x TIME(ns)=%u\n", data, command >> 24, (command >> 16) & 0xff,
65+
command & 0xff, time);
6466
}
6567

6668
auto Sca::read() -> ReadResult
6769
{
6870
auto data = barRead(Registers::READ_DATA);
6971
auto command = barRead(Registers::READ_COMMAND);
72+
// printf("Sca::read DATA=0x%x CH=0x%x TR=0x%x CMD=0x%x\n", data, command >> 24, (command >> 16) & 0xff, command & 0xff);
7073
checkError(command);
7174
return { data, command };
7275
}
@@ -121,7 +124,8 @@ void Sca::gpioEnable()
121124

122125
auto Sca::gpioWrite(uint32_t data) -> ReadResult
123126
{
124-
init();
127+
// printf("Sca::gpioWrite DATA=0x%x\n", data);
128+
initialize();
125129
// WR REGISTER OUT DATA
126130
write(0x02040010, data);
127131
// RD DATA

0 commit comments

Comments
 (0)