ページ 36 EMX ユーザー マニュアルには次のように記載されています。ただし、Redpine Signals RS9110-N-11-21 データシートには、「アクティブ ハイ、レベル トリガー」と記載されています。割り込みは、WiFi デバイスによってトリガーされます。C# コード内で InterruptEdgeLevelHigh または InterruptEdgeLevelLow のパラメーターを使用すると、引数例外が発生します。EMXのユーザーマニュアルと一致しているので問題ありません。InterruptEdgeBoth、InterruptEdgeHigh、または InterruptEdgeLow を使用すると、割り込みを受け取ることができません。デバイスが「アクティブ ハイ、レベル トリガー」を使用しているためかどうかはわかりません。
RedPine が「トリガーされるレベル」に制限されている場合、エッジがトリガーされた状態で割り込みを検出できるはずですか、それとも割り込み検出は完全にレベルに制限されていますか?
トリガーをテストするために使用しているコードの一部を次に示します。
public static void Main()
{
config = new SPI.Configuration((Cpu.Pin)EMX.Pin.IO2, false, 0, 0, false, true, 1000, SPI.SPI_module.SPI1);
SPI1 = new SPI(config);
WiFiReset = new OutputPort((Cpu.Pin)EMX.Pin.IO3, true);
WiFiInterrupt = new InterruptPort((Cpu.Pin)EMX.Pin.IO26, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);
// "Interrupts can be activated on rising or falling edges with an optional glitch filter." Page 36 EMX User Manual.
// Redpine Datasheet: "Active high, level triggered."
// NETMF interrupt event: "If an InterruptEdgeLevelHigh or InterruptEdgeLevelLow interrupt event occurs, an application must call the ClearInterrupt method to re-enable this event."
WiFiInterrupt.OnInterrupt += new NativeEventHandler(WiFiInterrupt_OnInterrupt);
try
{
byte[] in_initialise = { 0x15, 0x00 }; //initialisation
byte[] out_initialise = new byte[2];
SPI1.WriteRead(in_initialise, out_initialise);
if (out_initialise[1] != 0x58) //SUCCESSFUL
{
WiFiReset.Write(false);
Thread.Sleep(1);
WiFiReset.Write(true);
SPI1.WriteRead(in_initialise, out_initialise);
}
if (out_initialise[1] == 0x58)
{
Debug.Print("WiFi is Initialised.");
WiFiInterrupt.ClearInterrupt();
intFlag = false;
byte[] in_bandStart = { 0x7c, 0x04, 0x10, 0x00, 0x02, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00 }; //Band
byte[] out_bandStart = new byte[20];
SPI1.WriteRead(in_bandStart, out_bandStart);
if (out_bandStart[19] == 0x58) //SUCCESSFUL
{
//Debug.Print("WiFi established Band Command Start.");
while (intFlag == false && delay < maxDelay)
{
++delay; //waiting for interrupt
SPI1.WriteRead(tx_data, rx_data);
if (rx_data[0] == 0x55)
break;
Thread.Sleep(1);
}
if (delay != maxDelay)
{
*****************************************************************************************************
static void WiFiInterrupt_OnInterrupt(uint data1, uint data2, DateTime time)
{
byte[] in_intStart = { 0x5c, 0x00, 0x10, 0x00 }; //Band Start
byte[] out_intStart = new byte[4];
SPI1.WriteRead(in_intStart, out_intStart);
intFlag = true;
intTime = time;
}
最初の割り込みが発生する時点で、受信を確認する 0x58 をすでに数回受信しています (「割り込みの待機」を参照)。
Band Command Start
Send : 7c Recv : 00
Send : 04 Recv : 58
Send : 10 Recv : 58
Send : 00 Recv : 58
Send : 02 Recv : 58
Send : 18 Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 04 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Wait for interrupt
Interrupt received, Do master read
Send : 5c Recv : 00
Send : 00 Recv : 58
Send : 10 Recv : 58
Send : 00 Recv : 58
wait for start token
Send : Dummy 00 Recv : 58
Send : Dummy 00 Recv : 58
Send : Dummy 00 Recv : 55
Read descriptor is
Send : Dummy 00 Recv : 00
Send : Dummy 00 Recv : 97 .........Band Success Response
Send : Dummy 00 Recv : 00
Send : Dummy 00 Recv : 00
Send : Dummy 00 Recv : 00
Send : Dummy 00 Recv : 00
Send : Dummy 00 Recv : 00
Send : Dummy 00 Recv : 55
Send : Dummy 00 Recv : 88
Send : Dummy 00 Recv : 01
Send : Dummy 00 Recv : 00
Send : Dummy 00 Recv : 00
Send : Dummy 00 Recv : d1
Send : Dummy 00 Recv : 27
Send : Dummy 00 Recv : 04
Send : Dummy 00 Recv : 00
Band Response =97 Status=00
--------------------------------------------
Init Start
Send : 7c Recv : 80
Send : 04 Recv : 58
Send : 10 Recv : 58
Send : 00 Recv : 58
Send : 00 Recv : 58
Send : 10 Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
Send : 00 Dummy Recv : 58
どんなコメントでも大歓迎です。
ケビン。