Hilscher netX microcontroller driver  V0.0.5.0
Documentation of the netX driver package
netx_drv_biss.c
Go to the documentation of this file.
1 /**************************************************************************/
19 #include "netx_drv_user_conf.h"
20 #ifdef DRV_BISS_MODULE_ENABLED
21 
32 /*****************************************************************************/
33 /* Includes */
34 /*****************************************************************************/
35 #ifdef DRV_DEVICE_NETX_90_MPW
36 #error "The MPW chip is no longer supported!"
37 #else
38 #ifdef DRV_DEVICE_NETX_90
39 #include "regdef/netx90_app/regdef_netx90_arm_app.h"
40 #else
41 #error "No chip Selected!"
42 #endif
43 #endif
44 #include "netx_drv_biss.h"
45 #include <string.h>
46 
47 /*****************************************************************************/
48 /* Definitions */
49 /*****************************************************************************/
50 #ifndef DRV_BISSM_INST
51 #define DRV_BISSM_INST 0
52 #endif
53 
54 #define DRV_BISSM_CTRL_CHN_CNT 8
55 #define DRV_BISSM_CTRL_REG_CNT 64
56 
57 #define DRV_BISSM_INSTR_CDM1 0x1UL
58 #define DRV_BISSM_INSTR_CDM0 0x2UL
59 #define DRV_BISSM_INSTR_REGCOM 0x4UL
60 #define DRV_BISSM_INSTR_REGCOM_REDUCE 0x7UL
61 
62 #define DRV_BISSM_CC_SL_CFG_BISS_B 0x0
63 #define DRV_BISSM_CC_SL_CFG_BISS_C 0x1
64 #define DRV_BISSM_CC_SL_CFG_SSI 0x2
65 
66 /*****************************************************************************/
67 /* Variables */
68 /*****************************************************************************/
69 
70 HW_PTR_BISS(s_aptBiss)
71 HW_PTR_BISS_CTRL(s_aptBissCtrl)
72 
73 /*****************************************************************************/
74 /* Functions */
75 /*****************************************************************************/
76 
77 
78 #ifndef _HW_CONCAT
79 #define _HW_CONCAT(a,b) a ## b
80 #define HW_MSK(bf) _HW_CONCAT(MSK_NX90_, bf)
81 #define HW_SRT(bf) _HW_CONCAT(SRT_NX90_, bf)
82 #define HW_DFLT_BF_VAL(bf) _HW_CONCAT(DFLT_BF_VAL_NX90_, bf)
83 #define HW_DFLT_VAL(reg) _HW_CONCAT(DFLT_VAL_NX90_, reg)
84 #define HW_REGADR(reg) _HW_CONCAT(Adr_NX90_, reg)
85 #define HW_AREAADR(area) _HW_CONCAT(Addr_NX90_, area)
86 #define HW_TYPE(area) _HW_CONCAT(NX90_, area)
87 #endif
88 
89 #ifndef HW_WR32
90 #define HW_WR32(var,val) (var) = (val)
91 #endif
92 
93 #ifndef HW_RD32
94 #define HW_RD32(var) (var)
95 #endif
96 
97 #ifndef HW_WR16
98 #define HW_WR16(var,val) (var) = (val)
99 #endif
100 
101 #ifndef HW_RD16
102 #define HW_RD16(var) (var)
103 #endif
104 
105 #ifndef HW_WR8
106 #define HW_WR8(var,val) (var) = (val)
107 #endif
108 
109 #ifndef HW_RD8
110 #define HW_RD8(var) (var)
111 #endif
112 
113 /*****************************************************************************/
125 /*****************************************************************************/
127  void* pvUser )
128 {
129  unsigned int uiIdx;
130  uintptr_t pulSCD;
131  DRV_BISSM_RESULT_E ret;
132  if(DRV_BISSM_OK != (ret = DRV_BissM_Stop()))
133  {
134  return ret;
135  }
136 
137  HW_WR32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ccc1_mc0, 1UL << HW_SRT(biss_ccc1_mc0_CHSEL)
138  | HW_MSK(biss_ccc1_mc0_REGVERS)
139  );
140 
141 
142  pulSCD = (uintptr_t)s_aptBiss[DRV_BISSM_INST]->aulBiss_scdata0_;
143  for(uiIdx = 0; uiIdx < DRV_BISSM_CTRL_CHN_CNT; ++uiIdx)
144  {
145  HW_WR32(s_aptBiss[DRV_BISSM_INST]->aulBiss_sc[uiIdx], HW_MSK(biss_sc0_LSTOP0));
146  HW_WR32(((uint32_t*)pulSCD)[0], 0);
147  pulSCD+=4;
148  HW_WR32(((uint32_t*)pulSCD)[0], 0);
149  pulSCD+=4;
150  }
151 
152  for(uiIdx = 0; uiIdx < (DRV_BISSM_CTRL_REG_CNT/sizeof(uint32_t)); ++uiIdx)
153  {
154  HW_WR32(s_aptBiss[DRV_BISSM_INST]->aulBiss_rdata[uiIdx], 0);
155  }
156 
157  HW_WR32(s_aptBiss[DRV_BISSM_INST]->ulBiss_cc_sl, 1 | (DRV_BISSM_CC_SL_CFG_BISS_C << HW_SRT(biss_cc_sl_CFGCH1)));
158 
159  HW_WR32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ccc0, 0);
160 
161  HW_WR32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ir, HW_MSK(biss_ir_BREAK));
162 
164 
165  return DRV_BISSM_OK;
166 }
167 
168 /*****************************************************************************/
179 /*****************************************************************************/
181 {
182  uint32_t ulVal;
183  DRV_BISSM_RESULT_E ret;
184  if(DRV_BISSM_OK != (ret = DRV_BissM_Stop()))
185  {
186  return ret;
187  }
188  s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_trigger_cfg = (uint32_t)eTriggerCfg;
189  ulVal = s_aptBiss[DRV_BISSM_INST]->ulBiss_mc1;
190  ulVal &= ~(HW_MSK(biss_mc1_FREQAGS));
191  ulVal |= 0x7F << HW_SRT(biss_mc1_FREQAGS);
192  s_aptBiss[DRV_BISSM_INST]->ulBiss_mc1 = ulVal;
193  s_aptBiss[DRV_BISSM_INST]->ulBiss_ir |= HW_MSK(biss_ir_AGS);
194  return DRV_BISSM_OK;
195 }
196 
197 /*****************************************************************************/
206 /*****************************************************************************/
208 {
209  uint32_t ulVal;
210  DRV_BISSM_RESULT_E ret;
211  if(DRV_BISSM_OK != (ret = DRV_BissM_Stop()))
212  {
213  return ret;
214  }
215  s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_trigger_cfg = 0;
216  ulVal = s_aptBiss[DRV_BISSM_INST]->ulBiss_mc1;
217  ulVal &= ~(HW_MSK(biss_mc1_FREQAGS));
218  ulVal |= 0x7C << HW_SRT(biss_mc1_FREQAGS);
219  s_aptBiss[DRV_BISSM_INST]->ulBiss_mc1 = ulVal;
220  s_aptBiss[DRV_BISSM_INST]->ulBiss_ir |= HW_MSK(biss_ir_AGS);
221  return DRV_BISSM_OK;
222 }
223 
224 /*****************************************************************************/
235 /*****************************************************************************/
236 DRV_BISSM_RESULT_E DRV_BissM_StartCycle( uint32_t ulCycleTimeUs )
237 {
238  uint32_t ulVal;
239  DRV_BISSM_RESULT_E ret;
240  if(ulCycleTimeUs > 4000) /* 4ms is max cycle time */
241  {
243  }
244  else if(ulCycleTimeUs > 123)
245  {
246  ulCycleTimeUs *= 20;
247  ulCycleTimeUs += 624;
248  ulCycleTimeUs /= 625;
249  if(ulCycleTimeUs > 0x80)
250  {
252  }
253  ulCycleTimeUs += 0x7F;
254  }
255  if(DRV_BISSM_OK != (ret = DRV_BissM_Stop()))
256  {
257  return ret;
258  }
259  s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_trigger_cfg = 0;
260  ulVal = s_aptBiss[DRV_BISSM_INST]->ulBiss_mc1;
261  ulVal &= ~(HW_MSK(biss_mc1_FREQAGS));
262  ulVal |= ulCycleTimeUs << HW_SRT(biss_mc1_FREQAGS);
263  s_aptBiss[DRV_BISSM_INST]->ulBiss_mc1 = ulVal;
264  s_aptBiss[DRV_BISSM_INST]->ulBiss_ir |= HW_MSK(biss_ir_AGS);
265  return DRV_BISSM_OK;
266 }
267 
268 /*****************************************************************************/
276 /*****************************************************************************/
278 {
279  s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_trigger_cfg = 0;
280  s_aptBiss[DRV_BISSM_INST]->ulBiss_ir &= ~HW_MSK(biss_ir_AGS);
281  while(!(s_aptBiss[DRV_BISSM_INST]->ulBiss_status0 & HW_MSK(biss_status0_EOT)))
282  {
283  /* wait for stop */
284  }
285 
286  return DRV_BISSM_OK;
287 }
288 
289 /*****************************************************************************/
298 /*****************************************************************************/
300 {
301  uint32_t ulVal;
302  if( 0 == (HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_status0) & HW_MSK(biss_status0_REGEND)))
303  {
305  }
306 
307  ulVal = DRV_BISSM_INSTR_REGCOM << HW_SRT(biss_ir_INSTR);
308  HW_WR32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ir, ulVal | HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ir));
309 
310  return DRV_BISSM_OK;
311 }
312 
313 /*****************************************************************************/
325 /*****************************************************************************/
327  uint32_t ulPrmVal )
328 {
329  uint32_t ulVal;
330 
331  switch(ePrmID)
332  {
334  break;
335 
337  ulVal = HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ccc1_mc0) & ~HW_MSK(biss_ccc1_mc0_FREQS);
338  ulPrmVal = (ulPrmVal + 9) / 10 - 1;
339  if(ulPrmVal > 0xF)
340  {
342  }
343  ulVal |= (ulPrmVal << HW_SRT(biss_ccc1_mc0_FREQS));
344  HW_WR32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ccc1_mc0, ulVal);
345  break;
346 
348  break;
349 
351  break;
352 
354  break;
355 
357  HW_WR32(s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_irq_msk_reset, ~ulPrmVal);
358  HW_WR32(s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_irq_msk_set, ulPrmVal);
359  break;
360 
362  break;
363 
365  if(ulPrmVal != 0)
366  {
367  ulVal = HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_mc1) & ~HW_MSK(biss_mc1_FREQAGS);
368  ulVal |= 0x7F << HW_SRT(biss_mc1_FREQAGS);
369  HW_WR32(s_aptBiss[DRV_BISSM_INST]->ulBiss_mc1, ulVal);
370  }
371  HW_WR32(s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_trigger_cfg, ulPrmVal);
372  break;
373 
375  HW_WR32(s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_trigger, ulPrmVal);
376  break;
377 
378  default:
380  }
381 
382  return DRV_BISSM_OK;
383 }
384 
385 #if 0
386 static uint8_t DRV_BissM_CalcCrcMagic(uint32_t ulCrcPoly)
387 {
388  uint8_t bMask;
389  uint8_t bCrc = 0;
390  unsigned int uCrcLen;
391  unsigned int uIdx;
392 
393  ulCrcPoly >>= 1;
394 
395  if (ulCrcPoly == 0)
396  {
397  /* CRC is not used */
398  return 0;
399  }
400 
401  bMask = 0x80;
402  uCrcLen = 8;
403 
404  /*-- setting the CRC mask and computing CRC length --*/
405  while (bMask > ulCrcPoly) {
406  bMask = (bMask >> 1);
407  uCrcLen--;
408  }
409 
410  ulCrcPoly = (ulCrcPoly << 1) + 1;
411 
412  uIdx = uCrcLen;
413  while( uIdx )
414  {
415  uIdx--;
416 
417  if( (bCrc & bMask) != 0 )
418  {
419  bCrc = (uint8_t)(bCrc << 1);
420  }
421  else
422  {
423  bCrc = (uint8_t)((bCrc << 1) ^ ulCrcPoly);
424  }
425  }
426 
427  bMask = (1 << uCrcLen) - 1;
428  bCrc &= bMask;
429 
430  return bCrc;
431 }
432 #endif
433 
434 /*****************************************************************************/
447 /*****************************************************************************/
450  uint32_t ulPrmVal )
451 {
452  uint32_t ulVal;
453  switch(ePrmID)
454  {
456  ulVal = HW_RD32(s_aptBiss[DRV_BISSM_INST]->aulBiss_sc[uChNo]);
457  if( ulPrmVal == DRV_BISSM_DATA_ACTIVE_ACTIVE )
458  {
459  ulVal |= HW_MSK(biss_sc0_ENSCD0);
460  }
461  else
462  {
463  ulVal &= ~HW_MSK(biss_sc0_ENSCD0);
464  }
465  HW_WR32(s_aptBiss[DRV_BISSM_INST]->aulBiss_sc[uChNo], ulVal);
466  break;
467 
469  if( ulPrmVal == DRV_BISSM_DATA_TYPE_ACT )
470  {
471  /* enable MO */
472  ulVal = HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ccc1_mc0);
473  ulVal |= HW_MSK(biss_ccc1_mc0_EN_MO);
474  HW_WR32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ccc1_mc0, ulVal);
475 
476  /* mark slave as actuator */
477  ulVal = HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_cc_sl);
478  ulVal |= 1UL << (uChNo+ HW_SRT(biss_cc_sl_ACTnSENS));
479  HW_WR32(s_aptBiss[DRV_BISSM_INST]->ulBiss_cc_sl, ulVal);
480  }
481  else
482  {
483  /* mark slave as sensor */
484  ulVal = HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_cc_sl);
485  ulVal &= ~(1UL << (uChNo+ HW_SRT(biss_cc_sl_ACTnSENS)));
486  HW_WR32(s_aptBiss[DRV_BISSM_INST]->ulBiss_cc_sl, ulVal);
487 
488  /* any actuators left? */
489  if( 0 == (ulVal & HW_MSK(biss_cc_sl_ACTnSENS)) )
490  {
491  /* disable MO */
492  ulVal = HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ccc1_mc0);
493  ulVal &= ~HW_MSK(biss_ccc1_mc0_EN_MO);
494  HW_WR32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ccc1_mc0, ulVal);
495  }
496  }
497 
498  break;
499 
501  ulVal = HW_RD32(s_aptBiss[DRV_BISSM_INST]->aulBiss_sc[uChNo]) & ~HW_MSK(biss_sc0_SCDLEN0);
502  ulVal |= (ulPrmVal - 1) << HW_SRT(biss_sc0_SCDLEN0);
503  HW_WR32(s_aptBiss[DRV_BISSM_INST]->aulBiss_sc[uChNo], ulVal);
504  break;
505 
507  /* only data right aligned is supported. Configuration of left aligned data is not supported yet */
508  break;
509 
511  ulVal = HW_RD32(s_aptBiss[DRV_BISSM_INST]->aulBiss_sc[uChNo]) & ~(HW_MSK(biss_sc0_SCRCPOLY0) | HW_MSK(biss_sc0_SELCRCS0));
512 
513  switch(ulPrmVal)
514  {
515  case 0x00000: break;
516  case 0x0000b: ulVal |= (0x03 << HW_SRT(biss_sc0_SCRCPOLY0)); break;
517  case 0x00013: ulVal |= (0x04 << HW_SRT(biss_sc0_SCRCPOLY0)); break;
518  case 0x00025: ulVal |= (0x05 << HW_SRT(biss_sc0_SCRCPOLY0)); break;
519  case 0x00043: ulVal |= (0x06 << HW_SRT(biss_sc0_SCRCPOLY0)); break;
520  case 0x00089: ulVal |= (0x07 << HW_SRT(biss_sc0_SCRCPOLY0)); break;
521  case 0x0012f: ulVal |= (0x08 << HW_SRT(biss_sc0_SCRCPOLY0)); break;
522  case 0x190d9: ulVal |= (0x10 << HW_SRT(biss_sc0_SCRCPOLY0)); break;
523  default:
524  if(0 != (ulPrmVal & 0xffffff00UL))
525  {
527  }
528  ulVal |= HW_MSK(biss_sc0_SELCRCS0);
529  ulVal |= (ulPrmVal >> 1) << HW_SRT(biss_sc0_SCRCPOLY0);
530  break;
531  }
532 
533  HW_WR32(s_aptBiss[DRV_BISSM_INST]->aulBiss_sc[uChNo], ulVal);
534  break;
535 
537  ulVal = HW_RD32(s_aptBiss[DRV_BISSM_INST]->aulBiss_sc[uChNo]) & ~HW_MSK(biss_sc0_SCRCSTART0);
538  ulVal |= ulPrmVal << HW_SRT(biss_sc0_SCRCSTART0);
539  HW_WR32(s_aptBiss[DRV_BISSM_INST]->aulBiss_sc[uChNo], ulVal);
540  break;
541 
543  break;
544 
546  break;
547 
549  break;
550 
551  default:
553  }
554  return DRV_BISSM_OK;
555 }
556 
557 
558 /*****************************************************************************/
571 /*****************************************************************************/
573 {
574  uint32_t ulStatus0 = HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_status0);
575  ptState->fBusy = ( 0 == (ulStatus0 & HW_MSK(biss_status0_EOT)));
576 
577  ptState->fSlaveRdy = ( 0 != (HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_status1) & HW_MSK(biss_status1_SL1)) );
578 
579  ptState->eError = (0 == (ulStatus0 & HW_MSK(biss_status0_nSCDERR)) ) ? DRV_BISSM_FRM_ERR_SLAVE_NRDY : DRV_BISSM_FRM_OK;
580 
581  ptState->usCycleCnt = 0;
582 
583  return DRV_BISSM_OK;
584 }
585 
586 
587 /*****************************************************************************/
598 /*****************************************************************************/
600  const uint8_t *pbData )
601 {
602  uint32_t ulData;
603  volatile uint32_t* pulSCD;
604 
605  pulSCD = s_aptBiss[DRV_BISSM_INST]->aulBiss_scdata0_ + 2 * uChNo;
606 
607  ulData = pbData[0]
608  + ((uint32_t)pbData[1] << 8)
609  + ((uint32_t)pbData[2] << 16)
610  + ((uint32_t)pbData[3] << 24);
611  HW_WR32(pulSCD[0], ulData);
612  ulData = pbData[4]
613  + ((uint32_t)pbData[5] << 8)
614  + ((uint32_t)pbData[6] << 16)
615  + ((uint32_t)pbData[7] << 24);
616  HW_WR32(pulSCD[1], ulData);
617 
618 
619  return DRV_BISSM_OK;
620 }
621 
622 
623 /*****************************************************************************/
636 /*****************************************************************************/
638  DRV_BISSM_DATA_STATE_E *peStatus,
639  uint16_t *pusCycleCnt,
640  uint8_t *pbData )
641 {
642  unsigned int uIdx;
643  uint32_t ulState;
644  volatile uint32_t* pulSCD;
645 
646  union {
647  uint32_t aul[2];
648  uint8_t ab[8];
649  } data;
650 
651  pulSCD = s_aptBiss[DRV_BISSM_INST]->aulBiss_scdata0_ + 2 * uChNo;
652 
653  *peStatus = DRV_BISSM_DATA_OK;
654 
655  /* 2 bytes cycle counter */
656  if( pusCycleCnt != NULL )
657  {
658  *pusCycleCnt = 0;
659  }
660 
661  data.aul[0] = HW_RD32(pulSCD[0]);
662  data.aul[1] = HW_RD32(pulSCD[1]);
663 
664  for( uIdx = 0; uIdx < 8; ++uIdx)
665  {
666  pbData[uIdx] = data.ab[uIdx];
667  }
668 
669  /* status */
670  ulState = HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_status0);
671 
672  if( 0 == (ulState & HW_MSK(biss_status0_nSCDERR)) )
673  {
674  *peStatus = DRV_BISSM_DATA_ERR_FRM;
675  return DRV_BISSM_OK;
676  }
677 
678  if( 0 == (ulState & (HW_MSK(biss_status0_SVALID0) << (2 * uChNo))) )
679  {
680  *peStatus = DRV_BISSM_DATA_ERR_CRC;
681  return DRV_BISSM_OK;
682  }
683 
684  return DRV_BISSM_OK;
685 }
686 
687 
688 /*****************************************************************************/
706 /*****************************************************************************/
708  DRV_BISSM_DATA_STATE_E *peStatus,
709  uint16_t *pusCycleCnt,
710  uint8_t *pbData )
711 {
712 #if 0
713  uint8_t* pbFrameData;
714  DRV_BISSM_FRM_ERR_E bBissState;
715 
716 #ifndef __DRV_BISSM_DISABLE_CHECKS__
717  if( uChNo > DRV_BISSM_CHANNEL_CNT )
719 #endif
720 
721 
722  /* 1 byte data */
723  pbFrameData = (uint8_t*)&s_ptXpicShm->atXPIC_SHM_FRAME_DATA[uChNo];
724 
725  pbData[0] = NX_READ8(pbFrameData[DRV_BISSM_OFS_FRAME_DATA_EXT]);
726 
727  /* 1 byte status */
728  bBissState = pbFrameData[DRV_BISSM_OFS_FRAME_DATA_STATE];
729 
730  /* 2 bytes cycle counter */
731  if( pusCycleCnt != NULL )
732  {
733  *pusCycleCnt = NX_READ8(pbFrameData[DRV_BISSM_OFS_FRAME_DATA_CYCLE])
734  | (NX_READ8(pbFrameData[DRV_BISSM_OFS_FRAME_DATA_CYCLE + 1]) << 8);
735  }
736 
737  if( bBissState != 0 )
738  {
739  *peStatus = DRV_BISSM_DATA_ERR_FRM;
740  return DRV_BISSM_OK;
741  }
742 
743  /* CRC OK? */
744  if( s_abExtCrcMagic[uChNo] != NX_READ8(pbFrameData[DRV_BISSM_OFS_FRAME_DATA_EXT_CRC]) )
745  {
746  *peStatus = DRV_BISSM_DATA_ERR_CRC;
747  }
748  else
749  {
750  *peStatus = DRV_BISSM_DATA_OK;
751  }
752 #endif
753 
754  return DRV_BISSM_OK;
755 }
756 
757 
758 /*****************************************************************************/
772 /*****************************************************************************/
774  unsigned int uOpcode )
775 {
776  uint32_t ulStatus0 = HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_status0);
777  uint32_t ulVal;
778 
779  if( 0 == (ulStatus0 & HW_MSK(biss_status0_CDMTIMEOUT)))
780  {
782  }
783 
784  ulVal = HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ccc1_mc0);
785 
786  ulVal &= ~(HW_MSK(biss_ccc1_mc0_CTS)
787  |HW_MSK(biss_ccc1_mc0_CMD)
788  |HW_MSK(biss_ccc1_mc0_IDA_TEST)
789  );
790 
791  ulVal |= uOpcode << HW_SRT(biss_ccc1_mc0_CMD);
792  ulVal |= HW_MSK(biss_ccc1_mc0_REGVERS);
793 
794  if( uSlaveId != 0 )
795  {
796  /* broadcast, set EX bit immediately */
797  ulVal |= HW_MSK(biss_ccc1_mc0_IDA_TEST);
798  }
799 
800  HW_WR32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ccc1_mc0, ulVal);
801  HW_WR32(s_aptBiss[DRV_BISSM_INST]->aulBiss_rdata[0], uSlaveId);
802 
803  return DRV_BISSM_OK;
804 }
805 
806 
807 /*****************************************************************************/
820 /*****************************************************************************/
822  unsigned int uRegAdr,
823  unsigned int uRegNr,
824  unsigned int uWnR )
825 {
826  uint32_t ulStatus0 = HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_status0);
827  uint32_t ulVal;
828 
829  if( 0 == (ulStatus0 & HW_MSK(biss_status0_CDMTIMEOUT)))
830  {
832  }
833 
834  if(uSlaveId > 7)
835  {
837  }
838 
839  ulVal = HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ccc1_mc0);
840  ulVal &= ~(HW_MSK(biss_ccc1_mc0_CMD)
841  |HW_MSK(biss_ccc1_mc0_IDA_TEST));
842  ulVal |= HW_MSK(biss_ccc1_mc0_CTS);
843  ulVal |= HW_MSK(biss_ccc1_mc0_REGVERS);
844  ulVal |= uSlaveId << HW_SRT(biss_ccc1_mc0_IDA_TEST);
845  HW_WR32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ccc1_mc0, ulVal);
846 
847  HW_WR32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ccc0,(uRegAdr << HW_SRT(biss_ccc0_REGADR))
848  |((uRegNr - 1) << HW_SRT(biss_ccc0_REGNUM))
849  |(uWnR << HW_SRT(biss_ccc0_WNR)));
850 
851  return DRV_BISSM_OK;
852 }
853 
854 
855 /*****************************************************************************/
863 /*****************************************************************************/
865 {
866  return DRV_BISSM_OK;
867 }
868 
869 
870 /*****************************************************************************/
881 /*****************************************************************************/
883  const uint8_t *pbData )
884 {
885  unsigned int uiCnt;
886  uint32_t ulData = 0;
887 #ifndef __DRV_BISSM_DISABLE_CHECKS__
888  if( uRegCnt > DRV_BISSM_CTRL_REG_CNT )
890  if( pbData == NULL )
892 #endif
893 
894  for(uiCnt = 0; uiCnt < uRegCnt; ++uiCnt)
895  {
896  unsigned int uiByte = uiCnt & 0x3;
897  ulData = ulData | ((uint32_t)pbData[uiCnt] << (8 * uiByte));
898  if( (uiCnt & 0x3) == 3)
899  {
900  /* write 4 bytes at once */
901  HW_WR32(s_aptBiss[DRV_BISSM_INST]->aulBiss_rdata[uiCnt >> 2], ulData);
902  ulData = 0;
903  }
904  }
905 
906  /* write remaining bytes */
907  if(0 != (uRegCnt & 0x3))
908  {
909  HW_WR32(s_aptBiss[DRV_BISSM_INST]->aulBiss_rdata[uRegCnt >> 2], ulData);
910  }
911 
912  return DRV_BISSM_OK;
913 }
914 
915 
916 /*****************************************************************************/
927 /*****************************************************************************/
929  uint8_t *pbData )
930 {
931  uint32_t ulData = 0;
932  unsigned int uiIdx;
933 
934 #ifndef __DRV_BISSM_DISABLE_CHECKS__
935  if( uRegCnt > DRV_BISSM_CTRL_REG_CNT )
937  if( pbData == NULL )
939 #endif
940 
941  for(uiIdx = 0; uiIdx < uRegCnt; ++uiIdx)
942  {
943  if( (uiIdx & 0x3) == 0 )
944  {
945  ulData = HW_RD32(s_aptBiss[DRV_BISSM_INST]->aulBiss_rdata[uiIdx >> 2]);
946  }
947 
948  pbData[uiIdx] = ulData & 0xff;
949  ulData >>= 8;
950  }
951 
952 
953  return DRV_BISSM_OK;
954 }
955 
956 
957 /*****************************************************************************/
971 /*****************************************************************************/
973 {
974  uint32_t ulStatus0 = HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_status0);
975 
976  ptCtrlState->fBusy = ( 0 == (ulStatus0 & HW_MSK(biss_status0_CDMTIMEOUT)) );
977  ptCtrlState->eError = ( 0 == (ulStatus0 & HW_MSK(biss_status0_nREGERR)) ) ? DRV_BISSM_CTRL_ERR_BISS_FRAME_ERR : DRV_BISSM_CTRL_OK;
978 
979  return DRV_BISSM_OK;
980 }
981 
982 
983 /*****************************************************************************/
996 /*****************************************************************************/
997 uint32_t DRV_BissM_GetIrqRaw( void )
998 {
999  uint32_t ulVal = HW_RD32(s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_irq_raw);
1000  return ulVal;
1001 }
1002 
1003 
1004 /*****************************************************************************/
1017 /*****************************************************************************/
1018 void DRV_BissM_ConfirmIrq( uint32_t ulIrqMsk )
1019 {
1020  HW_WR32(s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_irq_raw, ulIrqMsk);
1021 }
1022 
1023 
1024 /*****************************************************************************/
1037 /*****************************************************************************/
1038 uint32_t DRV_BissM_GetIrq( void )
1039 {
1040  uint32_t ulVal = HW_RD32(s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_irq_masked);
1041  return ulVal;
1042 }
1043 
1044 
1045 /*****************************************************************************/
1058 /*****************************************************************************/
1059 void DRV_BissM_IrqEnable( uint32_t ulIrqMsk )
1060 {
1061  HW_WR32(s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_irq_msk_set, ulIrqMsk);
1062 }
1063 
1064 
1065 /*****************************************************************************/
1078 /*****************************************************************************/
1079 void DRV_BissM_IrqDisable( uint32_t ulIrqMsk )
1080 {
1081  HW_WR32(s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_irq_msk_reset, ulIrqMsk);
1082 }
1083 
1084 
1085 /*****************************************************************************/
1098 /*****************************************************************************/
1099 uint32_t DRV_BissM_GetConfirmIrq( void )
1100 {
1101  uint32_t ulVal = HW_RD32(s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_irq_raw);
1102  HW_WR32(s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_irq_raw, ulVal);
1103  return ulVal;
1104 }
1105 
1106 /*****************************************************************************/
1114 /*****************************************************************************/
1116 {
1117  uint32_t ulVal = HW_RD32(s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_irq_raw);
1118  HW_WR32(s_aptBissCtrl[DRV_BISSM_INST]->ulBiss_ctrl_irq_raw, ulVal);
1119 }
1120 
1121 void DRV_BissM_Break( void )
1122 {
1123  HW_WR32(s_aptBiss[DRV_BISSM_INST]->ulBiss_ir, HW_MSK(biss_ir_BREAK));
1124 }
1125 
1126 uint32_t DRV_BissM_Status0( void )
1127 {
1128  return HW_RD32(s_aptBiss[DRV_BISSM_INST]->ulBiss_status0);
1129 }
1130 /* End of group BISS */
1132 
1133 #endif /* DRV_BISS_MODULE_DISABLED */
DRV_BISSM_RESULT_E
DRV_BISSM_FRM_ERR_E
DRV_BISSM_RESULT_E DRV_BissM_StartAgsMin(void)
uint32_t DRV_BissM_GetIrq(void)
DRV_BISSM_RESULT_E DRV_BissM_GetState(DRV_BISSM_STATE_T *ptState)
static ETH_XPIC_SHM_AREA_T * s_ptXpicShm
#define HW_PTR_BISS_CTRL(var)
Definition: netx_drv_biss.h:53
uint32_t DRV_BissM_Status0(void)
#define HW_PTR_BISS(var)
Definition: netx_drv_biss.h:47
DRV_BISSM_RESULT_E DRV_BissM_GetCtrlState(DRV_BISSM_CTRL_STATE_T *ptCtrlState)
DRV_BISSM_RESULT_E DRV_BissM_CtrlRst(void)
DRV_BISSM_RESULT_E DRV_BissM_CtrlStart(void)
DRV_BISSM_RESULT_E DRV_BissM_SetParam(DRV_BISSM_PARAM_E ePrmID, uint32_t ulPrmVal)
void DRV_BissM_ConfirmIrq(uint32_t ulIrqMsk)
DRV_BISSM_RESULT_E DRV_BissM_GetSsiExtData(unsigned int uChNr, DRV_BISSM_DATA_STATE_E *peStatus, uint16_t *pusCycleCnt, uint8_t *pbData)
DRV_BISSM_RESULT_E DRV_BissM_Init(DRV_BISSM_CFG_T *ptConfig, void *pvUser)
#define DRV_BISSM_CC_SL_CFG_BISS_C
Definition: netx_drv_biss.c:63
DRV_BISSM_CHANNEL_PARAM_E
#define DRV_BISSM_CTRL_REG_CNT
Definition: netx_drv_biss.c:55
DRV_BISSM_RESULT_E DRV_BissM_StartCycle(uint32_t ulCycleTimeUs)
DRV_BISSM_RESULT_E DRV_BissM_SetProcessData(unsigned int uChNr, const uint8_t *pbData)
#define NX_READ8(var)
void DRV_BissM_ConfirmAllIrq(void)
uint32_t DRV_BissM_GetIrqRaw(void)
#define DRV_BISSM_INST
Definition: netx_drv_biss.c:51
DRV_BISSM_RESULT_E DRV_BissM_StartCtrlReg(unsigned int uSlaveId, unsigned int uRegAdr, unsigned int uRegNr, unsigned int uWnR)
DRV_BISSM_TRIGGER_TYPE_E
DRV_BISSM_RESULT_E DRV_BissM_SetCtrlData(unsigned int uRegNr, const uint8_t *pbData)
DRV_BISSM_CTRL_RESULT_E eError
void DRV_BissM_Break(void)
#define HW_MSK(bf)
Definition: netx_drv_biss.c:80
#define HW_WR32(var, val)
Definition: netx_drv_biss.c:90
Header file of BISS controller module.
DRV_BISSM_RESULT_E DRV_BissM_StartCtrlCmd(unsigned int uSlaveId, unsigned int uOpcode)
DRV_BISSM_RESULT_E DRV_BissM_StartTrigger(DRV_BISSM_TRIGGER_TYPE_E eTriggerCfg)
DRV_BISSM_RESULT_E DRV_BissM_Stop()
#define DRV_BISSM_CTRL_CHN_CNT
Definition: netx_drv_biss.c:54
DRV_BISSM_DATA_STATE_E
#define DRV_BISSM_INSTR_REGCOM
Definition: netx_drv_biss.c:59
#define HW_SRT(bf)
Definition: netx_drv_biss.c:81
DRV_BISSM_RESULT_E DRV_BissM_SetChannelParam(unsigned int uChNr, DRV_BISSM_CHANNEL_PARAM_E ePrmID, uint32_t ulPrmVal)
uint32_t DRV_BissM_GetConfirmIrq(void)
void DRV_BissM_IrqDisable(uint32_t ulIrqMsk)
DRV_BISSM_PARAM_E
DRV_BISSM_FRM_ERR_E eError
DRV_BISSM_RESULT_E DRV_BissM_GetProcessData(unsigned int uChNr, DRV_BISSM_DATA_STATE_E *peStatus, uint16_t *pusCycleCnt, uint8_t *pbData)
DRV_BISSM_RESULT_E DRV_BissM_GetCtrlData(unsigned int uRegNr, uint8_t *pbData)
#define HW_RD32(var)
Definition: netx_drv_biss.c:94
void DRV_BissM_IrqEnable(uint32_t ulIrqMsk)