18static void shiftarray(u8 *buf)
37 res = sio2CmdGetPortCtrl1(0, pstate->stat70bit, pstate->model);
39 pdSetCtrl1(pstate->port, pstate->slot, res);
41 res = sio2CmdGetPortCtrl2(0, pstate->stat70bit);
43 pdSetCtrl2(pstate->port, pstate->slot, res);
45 res = pdGetRegData(0);
47 pdSetRegData(pstate->port, pstate->slot, res);
51 pdSetInSize(pstate->port, pstate->slot, res);
53 res = pdGetOutSize(0);
55 pdSetOutSize(pstate->port, pstate->slot, res);
57 sio2CmdSetReadData(0, pstate->inbuffer);
59 pdSetInBuffer(pstate->port, pstate->slot, 0, pstate->inbuffer);
61 SetEventFlag(pstate->eventflag, EF_PAD_TRANSFER_START);
63 WaitClearEvent(pstate->eventflag, EF_PAD_TRANSFER_DONE, WEF_AND|WEF_CLEAR, NULL);
65 res = pdGetError(pstate->port, pstate->slot);
69 pdGetOutBuffer(pstate->port, pstate->slot, 0, pstate->outbuffer);
71 if(pstate->stat70bit == 1) shiftarray(pstate->outbuffer);
73 if((pstate->outbuffer[1] != 0)
74 && (sio2cmdCheckId(pstate->outbuffer[1]) == 1))
76 if((pstate->outbuffer[1] != 0)
77 && (sio2cmdCheckId(pstate->outbuffer[1]) == 1))
79 pstate->modeCurId = pstate->outbuffer[1];
85 SetEventFlag(pstate->eventflag, EF_TASK_DONE);
95 res = sio2CmdGetPortCtrl1(PAD_ID_CONFIG, pstate->stat70bit, pstate->model);
97 pdSetCtrl1(pstate->port, pstate->slot, res);
99 res = sio2CmdGetPortCtrl2(PAD_ID_CONFIG, pstate->stat70bit);
101 pdSetCtrl2(pstate->port, pstate->slot, res),
103 res = pdGetRegData(PAD_ID_CONFIG);
105 pdSetRegData(pstate->port, pstate->slot, res);
107 res = pdGetInSize(PAD_ID_CONFIG);
109 pdSetInSize(pstate->port, pstate->slot, res);
111 res = pdGetOutSize(PAD_ID_CONFIG);
113 pdSetOutSize(pstate->port, pstate->slot, res);
115 sio2CmdSetSetVrefParam(PAD_ID_CONFIG, pstate->inbuffer);
117 pstate->inbuffer[3] = val;
118 pstate->inbuffer[4] = pstate->modeParam[val];
120 pdSetInBuffer(pstate->port, pstate->slot, 0, pstate->inbuffer);
122 SetEventFlag(pstate->eventflag, EF_PAD_TRANSFER_START);
124 WaitClearEvent(pstate->eventflag, EF_PAD_TRANSFER_DONE, WEF_AND|WEF_CLEAR, NULL);
126 if( pdGetError(pstate->port, pstate->slot) == 0)
128 pdGetOutBuffer(pstate->port, pstate->slot, 0, pstate->outbuffer);
130 if(pstate->stat70bit == 1) shiftarray(pstate->outbuffer);
132 if(pstate->outbuffer[1] == PAD_ID_CONFIG) ret = 1;
135 SetEventFlag(pstate->eventflag, EF_TASK_DONE);
145 res = sio2CmdGetPortCtrl1(pstate->modeCurId, pstate->stat70bit, pstate->model);
147 pdSetCtrl1(pstate->port, pstate->slot, res);
149 res = sio2CmdGetPortCtrl2(pstate->modeCurId, pstate->stat70bit);
151 pdSetCtrl2(pstate->port, pstate->slot, res);
153 res = pdGetRegData( pstate->modeCurId );
155 pdSetRegData( pstate->port, pstate->slot, res);
157 res = pdGetInSize( pstate->modeCurId );
159 pdSetInSize( pstate->port, pstate->slot, res);
161 res = pdGetOutSize( pstate->modeCurId );
163 pdSetOutSize(pstate->port, pstate->slot, res);
165 for(i=0; i < 32; i++)
167 pstate->inbuffer[i] = 0;
168 pstate->outbuffer[i] = 0;
171 sio2CmdSetReadData(pstate->modeCurId, pstate->inbuffer);
173 for(i=0; i < (u32)(pstate->ee_actDirectSize); i++)
175 if(pstate->ee_actAlignData.data[i] == 0xFF)
176 pstate->inbuffer[i+3] = pstate->ee_actAlignData.data[i];
178 pstate->inbuffer[i+3] = pstate->ee_actDirectData.data[i];
181 pdSetInBuffer(pstate->port, pstate->slot, 0, pstate->inbuffer);
183 SetEventFlag( pstate->eventflag, EF_PAD_TRANSFER_START);
185 WaitClearEvent( pstate->eventflag, EF_PAD_TRANSFER_DONE, WEF_AND|WEF_CLEAR, NULL);
187 res = pdGetError(pstate->port, pstate->slot);
191 pdGetOutBuffer(pstate->port, pstate->slot, 0, pstate->outbuffer);
195 if(pstate->stat70bit == 1) shiftarray( pstate->outbuffer );
198 SetEventFlag( pstate->eventflag, EF_TASK_DONE);
203u32 EnterConfigMode(u8 val,
padState_t *pstate)
208 res = sio2CmdGetPortCtrl1(val, pstate->stat70bit, pstate->model);
210 pdSetCtrl1(pstate->port, pstate->slot, res);
212 res = sio2CmdGetPortCtrl2(val, pstate->stat70bit);
214 pdSetCtrl2(pstate->port, pstate->slot, res);
216 res = pdGetRegData(val);
218 pdSetRegData(pstate->port, pstate->slot, res);
220 res = pdGetInSize(val);
222 pdSetInSize(pstate->port, pstate->slot, res);
224 res = pdGetOutSize(val);
226 pdSetOutSize(pstate->port, pstate->slot, res);
228 sio2CmdSetEnterConfigMode(val, pstate->inbuffer);
230 pdSetInBuffer(pstate->port, pstate->slot, 0, pstate->inbuffer);
232 SetEventFlag(pstate->eventflag, EF_PAD_TRANSFER_START);
234 WaitClearEvent(pstate->eventflag, EF_PAD_TRANSFER_DONE, WEF_AND|WEF_CLEAR, NULL);
236 if( pdGetError(pstate->port, pstate->slot) == 0)
238 pdGetOutBuffer(pstate->port, pstate->slot, 0, pstate->outbuffer);
240 if( pstate->stat70bit == 1)
242 shiftarray(pstate->outbuffer);
248 SetEventFlag(pstate->eventflag, EF_TASK_DONE);
259 res = sio2CmdGetPortCtrl1(PAD_ID_CONFIG, pstate->stat70bit, pstate->model);
261 pdSetCtrl1(pstate->port, pstate->slot, res);
263 res = sio2CmdGetPortCtrl2(PAD_ID_CONFIG, pstate->stat70bit);
265 pdSetCtrl2(pstate->port, pstate->slot, res);
267 res = pdGetRegData(PAD_ID_CONFIG);
269 pdSetRegData(pstate->port, pstate->slot, res);
271 res = pdGetInSize(PAD_ID_CONFIG);
273 pdSetInSize(pstate->port, pstate->slot, res);
275 res = pdGetOutSize(PAD_ID_CONFIG);
277 pdSetOutSize(pstate->port, pstate->slot, res);
279 sio2CmdSetQueryModel(PAD_ID_CONFIG, pstate->inbuffer);
281 pdSetInBuffer(pstate->port, pstate->slot, 0, pstate->inbuffer);
283 SetEventFlag(pstate->eventflag, EF_PAD_TRANSFER_START);
285 WaitClearEvent(pstate->eventflag, EF_PAD_TRANSFER_DONE, WEF_AND|WEF_CLEAR, NULL);
287 if( pdGetError(pstate->port, pstate->slot) == 0)
289 pdGetOutBuffer(pstate->port, pstate->slot, 0, pstate->outbuffer);
291 if( pstate->stat70bit == 1) shiftarray( pstate->outbuffer );
293 if( pstate->outbuffer[1] == PAD_ID_CONFIG)
295 pstate->numActuators = pstate->outbuffer[6];
296 pstate->model = pstate->outbuffer[3];
297 pstate->numModes = pstate->outbuffer[4];
298 pstate->modeCurOffs = pstate->outbuffer[5];
299 pstate->numActComb = pstate->outbuffer[7];
301 if( pstate->numActuators > 4) pstate->numActuators = 4;
302 if( pstate->numActComb > 4 ) pstate->numActComb = 4;
303 if( pstate->numModes > 4) pstate->numModes = 4;
309 SetEventFlag(pstate->eventflag, EF_TASK_DONE);
319 res = sio2CmdGetPortCtrl1(PAD_ID_CONFIG, pstate->stat70bit, pstate->model);
321 pdSetCtrl1(pstate->port, pstate->slot, res);
323 res = sio2CmdGetPortCtrl2(PAD_ID_CONFIG, pstate->stat70bit);
325 pdSetCtrl2(pstate->port, pstate->slot, res);
327 res = pdGetRegData(PAD_ID_CONFIG);
329 pdSetRegData(pstate->port, pstate->slot, res);
331 res = pdGetInSize(PAD_ID_CONFIG);
333 pdSetInSize(pstate->port, pstate->slot, res);
335 res = pdGetOutSize(PAD_ID_CONFIG);
337 pdSetOutSize(pstate->port, pstate->slot, res);
339 sio2CmdSetSetMainMode(PAD_ID_CONFIG, pstate->inbuffer);
341 pstate->inbuffer[3] = pstate->mode;
342 pstate->inbuffer[4] = pstate->lock;
344 pdSetInBuffer(pstate->port, pstate->slot, 0, pstate->inbuffer);
346 SetEventFlag(pstate->eventflag, EF_PAD_TRANSFER_START);
348 WaitClearEvent(pstate->eventflag, EF_PAD_TRANSFER_DONE, WEF_AND|WEF_CLEAR, NULL);
350 if( pdGetError(pstate->port, pstate->slot) == 0)
352 pdGetOutBuffer(pstate->port, pstate->slot, 0, pstate->outbuffer);
354 if(pstate->stat70bit == 1) shiftarray( pstate->outbuffer);
356 if(pstate->outbuffer[1] == PAD_ID_CONFIG) ret = 1;
360 SetEventFlag(pstate->eventflag, EF_TASK_DONE);
370 res = sio2CmdGetPortCtrl1(PAD_ID_CONFIG, pstate->stat70bit, pstate->model);
372 pdSetCtrl1(pstate->port, pstate->slot, res);
374 res = sio2CmdGetPortCtrl2(PAD_ID_CONFIG, pstate->stat70bit);
376 pdSetCtrl2(pstate->port, pstate->slot, res);
378 res = pdGetRegData(PAD_ID_CONFIG);
380 pdSetRegData(pstate->port, pstate->slot, res);
382 res = pdGetInSize(PAD_ID_CONFIG);
384 pdSetInSize(pstate->port, pstate->slot, res);
386 res = pdGetOutSize(PAD_ID_CONFIG);
388 pdSetOutSize(pstate->port, pstate->slot, res);
390 sio2CmdSetQueryAct(PAD_ID_CONFIG, pstate->inbuffer);
392 pstate->inbuffer[3] = actuator;
394 pdSetInBuffer(pstate->port, pstate->slot, 0, pstate->inbuffer);
396 SetEventFlag(pstate->eventflag, EF_PAD_TRANSFER_START);
398 WaitClearEvent(pstate->eventflag, EF_PAD_TRANSFER_DONE, WEF_AND|WEF_CLEAR, NULL);
400 if( pdGetError(pstate->port, pstate->slot) == 0)
402 pdGetOutBuffer(pstate->port, pstate->slot, 0, pstate->outbuffer);
404 if(pstate->stat70bit == 1) shiftarray( pstate->outbuffer );
406 if(pstate->outbuffer[1] == PAD_ID_CONFIG)
408 u8 *actData = pstate->actData.data[actuator];
410 actData[0] = pstate->outbuffer[5];
411 actData[1] = pstate->outbuffer[6];
412 actData[2] = pstate->outbuffer[7];
413 actData[3] = pstate->outbuffer[8];
419 SetEventFlag(pstate->eventflag, EF_TASK_DONE);
429 res = sio2CmdGetPortCtrl1(PAD_ID_CONFIG, pstate->stat70bit, pstate->model);
431 pdSetCtrl1(pstate->port, pstate->slot, res);
433 res = sio2CmdGetPortCtrl2(PAD_ID_CONFIG, pstate->stat70bit);
435 pdSetCtrl2(pstate->port, pstate->slot, res),
437 res = pdGetRegData(PAD_ID_CONFIG);
439 pdSetRegData(pstate->port, pstate->slot, res);
441 res = pdGetInSize(PAD_ID_CONFIG);
443 pdSetInSize(pstate->port, pstate->slot, res);
445 res = pdGetOutSize(PAD_ID_CONFIG);
447 pdSetOutSize(pstate->port, pstate->slot, res);
449 sio2CmdSetQueryComb(PAD_ID_CONFIG, pstate->inbuffer);
451 pstate->inbuffer[3] = val;
453 pdSetInBuffer(pstate->port, pstate->slot, 0, pstate->inbuffer);
455 SetEventFlag(pstate->eventflag, EF_PAD_TRANSFER_START);
457 WaitClearEvent(pstate->eventflag, EF_PAD_TRANSFER_DONE, WEF_AND|WEF_CLEAR, NULL);
459 if( pdGetError(pstate->port, pstate->slot) == 0)
461 pdGetOutBuffer(pstate->port, pstate->slot, 0, pstate->outbuffer);
463 if(pstate->stat70bit == 1) shiftarray(pstate->outbuffer);
465 if(pstate->outbuffer[1] == PAD_ID_CONFIG)
467 u8 *data = pstate->combData.data[val];
469 data[0] = pstate->outbuffer[5];
470 data[1] = pstate->outbuffer[6];
471 data[2] = pstate->outbuffer[7];
472 data[3] = pstate->outbuffer[8];
478 SetEventFlag(pstate->eventflag, EF_TASK_DONE);
489 res = sio2CmdGetPortCtrl1(PAD_ID_CONFIG, pstate->stat70bit, pstate->model);
491 pdSetCtrl1(pstate->port, pstate->slot, res);
493 res = sio2CmdGetPortCtrl2(PAD_ID_CONFIG, pstate->stat70bit);
495 pdSetCtrl2(pstate->port, pstate->slot, res),
497 res = pdGetRegData(PAD_ID_CONFIG);
499 pdSetRegData(pstate->port, pstate->slot, res);
501 res = pdGetInSize(PAD_ID_CONFIG);
503 pdSetInSize(pstate->port, pstate->slot, res);
505 res = pdGetOutSize(PAD_ID_CONFIG);
507 pdSetOutSize(pstate->port, pstate->slot, res);
509 sio2CmdSetQueryMode(PAD_ID_CONFIG, pstate->inbuffer);
511 pstate->inbuffer[3] = val;
513 pdSetInBuffer(pstate->port, pstate->slot, 0, pstate->inbuffer);
515 SetEventFlag(pstate->eventflag, EF_PAD_TRANSFER_START);
517 WaitClearEvent(pstate->eventflag, EF_PAD_TRANSFER_DONE, WEF_AND|WEF_CLEAR, NULL);
519 if( pdGetError(pstate->port, pstate->slot) == 0)
521 pdGetOutBuffer(pstate->port, pstate->slot, 0, pstate->outbuffer);
523 if(pstate->stat70bit == 1) shiftarray(pstate->outbuffer);
525 if(pstate->outbuffer[1] == PAD_ID_CONFIG)
527 u16 *modeTable = pstate->modeTable.data;
529 modeTable[val] = (pstate->outbuffer[5] << 8) | pstate->outbuffer[6];
535 SetEventFlag(pstate->eventflag, EF_TASK_DONE);
545 res = sio2CmdGetPortCtrl1(PAD_ID_CONFIG, pstate->stat70bit, pstate->model);
547 pdSetCtrl1(pstate->port, pstate->slot, res);
549 res = sio2CmdGetPortCtrl2(PAD_ID_CONFIG, pstate->stat70bit);
551 pdSetCtrl2(pstate->port, pstate->slot, res),
553 res = pdGetRegData(PAD_ID_CONFIG);
555 pdSetRegData(pstate->port, pstate->slot, res);
557 res = pdGetInSize(PAD_ID_CONFIG);
559 pdSetInSize(pstate->port, pstate->slot, res);
561 res = pdGetOutSize(PAD_ID_CONFIG);
563 pdSetOutSize(pstate->port, pstate->slot, res);
565 sio2CmdSetExitConfigMode(PAD_ID_CONFIG, pstate->inbuffer);
567 pdSetInBuffer(pstate->port, pstate->slot, 0, pstate->inbuffer);
569 SetEventFlag(pstate->eventflag, EF_PAD_TRANSFER_START);
571 WaitClearEvent(pstate->eventflag, EF_PAD_TRANSFER_DONE, WEF_AND|WEF_CLEAR, NULL);
573 if( pdGetError(pstate->port, pstate->slot) == 0)
575 pdGetOutBuffer(pstate->port, pstate->slot, 0, pstate->outbuffer);
577 if(pstate->stat70bit == 1) shiftarray(pstate->outbuffer);
582 SetEventFlag(pstate->eventflag, EF_TASK_DONE);
592 res = sio2CmdGetPortCtrl1(PAD_ID_CONFIG, pstate->stat70bit, pstate->model);
594 pdSetCtrl1(pstate->port, pstate->slot, res);
596 res = sio2CmdGetPortCtrl2(PAD_ID_CONFIG, pstate->stat70bit);
598 pdSetCtrl2(pstate->port, pstate->slot, res),
600 res = pdGetRegData(PAD_ID_CONFIG);
602 pdSetRegData(pstate->port, pstate->slot, res);
604 res = pdGetInSize(PAD_ID_CONFIG);
606 pdSetInSize(pstate->port, pstate->slot, res);
608 res = pdGetOutSize(PAD_ID_CONFIG);
610 pdSetOutSize(pstate->port, pstate->slot, res);
612 sio2CmdSetSetActAlign(PAD_ID_CONFIG, pstate->inbuffer);
615 pstate->inbuffer[3+i] = pstate->ee_actAlignData.data[i];
617 pdSetInBuffer(pstate->port, pstate->slot, 0, pstate->inbuffer);
619 SetEventFlag(pstate->eventflag, EF_PAD_TRANSFER_START);
621 WaitClearEvent(pstate->eventflag, EF_PAD_TRANSFER_DONE, WEF_AND|WEF_CLEAR, NULL);
623 if( pdGetError(pstate->port, pstate->slot) == 0)
625 pdGetOutBuffer(pstate->port, pstate->slot, 0, pstate->outbuffer);
627 if(pstate->stat70bit == 1) shiftarray(pstate->outbuffer);
629 if(pstate->outbuffer[1] == PAD_ID_CONFIG) ret = 1;
633 SetEventFlag(pstate->eventflag, EF_TASK_DONE);
643 res = sio2CmdGetPortCtrl1(PAD_ID_CONFIG, pstate->stat70bit, pstate->model);
645 pdSetCtrl1(pstate->port, pstate->slot, res);
647 res = sio2CmdGetPortCtrl2(PAD_ID_CONFIG, pstate->stat70bit);
649 pdSetCtrl2(pstate->port, pstate->slot, res),
651 res = pdGetRegData(PAD_ID_CONFIG);
653 pdSetRegData(pstate->port, pstate->slot, res);
655 res = pdGetInSize(PAD_ID_CONFIG);
657 pdSetInSize(pstate->port, pstate->slot, res);
659 res = pdGetOutSize(PAD_ID_CONFIG);
661 pdSetOutSize(pstate->port, pstate->slot, res);
663 sio2CmdSetQueryButtonMask(PAD_ID_CONFIG, pstate->inbuffer);
665 pdSetInBuffer(pstate->port, pstate->slot, 0, pstate->inbuffer);
667 SetEventFlag(pstate->eventflag, EF_PAD_TRANSFER_START);
669 WaitClearEvent(pstate->eventflag, EF_PAD_TRANSFER_DONE, WEF_AND|WEF_CLEAR, NULL);
671 if( pdGetError(pstate->port, pstate->slot) == 0)
673 pdGetOutBuffer(pstate->port, pstate->slot, 0, pstate->outbuffer);
675 if(pstate->stat70bit == 1) shiftarray(pstate->outbuffer);
677 if(pstate->outbuffer[8] == 0x5A)
679 pstate->buttonMask[0] = pstate->outbuffer[3];
680 pstate->buttonMask[1] = pstate->outbuffer[4];
681 pstate->buttonMask[2] = pstate->outbuffer[5];
682 pstate->buttonMask[3] = pstate->outbuffer[6];
686 pstate->buttonMask[0] = 0;
687 pstate->buttonMask[1] = 0;
688 pstate->buttonMask[2] = 0;
689 pstate->buttonMask[3] = 0;
695 SetEventFlag(pstate->eventflag, EF_TASK_DONE);
705 res = sio2CmdGetPortCtrl1(PAD_ID_CONFIG, pstate->stat70bit, pstate->model);
707 pdSetCtrl1(pstate->port, pstate->slot, res);
709 res = sio2CmdGetPortCtrl2(PAD_ID_CONFIG, pstate->stat70bit);
711 pdSetCtrl2(pstate->port, pstate->slot, res),
713 res = pdGetRegData(PAD_ID_CONFIG);
715 pdSetRegData(pstate->port, pstate->slot, res);
717 res = pdGetInSize(PAD_ID_CONFIG);
719 pdSetInSize(pstate->port, pstate->slot, res);
721 res = pdGetOutSize(PAD_ID_CONFIG);
723 pdSetOutSize(pstate->port, pstate->slot, res);
725 sio2CmdSetSetButtonInfo(PAD_ID_CONFIG, pstate->inbuffer);
728 pstate->inbuffer[3+i] = pstate->buttonInfo[i];
730 pdSetInBuffer(pstate->port, pstate->slot, 0, pstate->inbuffer);
732 SetEventFlag(pstate->eventflag, EF_PAD_TRANSFER_START);
734 WaitClearEvent(pstate->eventflag, EF_PAD_TRANSFER_DONE, WEF_AND|WEF_CLEAR, NULL);
736 if( pdGetError(pstate->port, pstate->slot) == 0)
738 pdGetOutBuffer(pstate->port, pstate->slot, 0, pstate->outbuffer);
740 if(pstate->stat70bit == 1) shiftarray(pstate->outbuffer);
742 if(pstate->outbuffer[1] == PAD_ID_CONFIG) ret = 1;
745 SetEventFlag(pstate->eventflag, EF_TASK_DONE);