📄 dps2spc3.c
字号:
if(real_buf_len[RBL_SSA] == 0)
{
/* SSA not supported */
spc3.r_ssa_buf_ptr = 0;
}
else
{
/* SSA supported */
spc3.r_ssa_buf_ptr = spc3.r_aux_buf_ptr[1] + (aux_buf_len[1]>>3);
}
/* set buffer-lens */
spc3.r_len_diag_buf[0] = spc3.r_len_diag_buf[1] = 6;
spc3.r_len_cfg_buf = dps2_binit.cfg_buf_len;
spc3.r_len_prm_buf = dps2_binit.prm_buf_len;
spc3.r_len_cntrl_buf[0] = aux_buf_len[0];
spc3.r_len_cntrl_buf[1] = aux_buf_len[1];
spc3.r_len_ssa_buf = dps2_binit.ssa_buf_len;
spc3.r_len_din_buf = spc3.r_len_dout_buf = 0;
/* init buffers */
spc_uptr = (UBYTE SPC3_PTR_ATTR*)&spc3.user;
for(r_din_dout_buf_len = 0; r_din_dout_buf_len < dps2_buf_len;r_din_dout_buf_len++)
{
*(spc_uptr + r_din_dout_buf_len) = 0;
}
if(fdl_init)
{
/* no buffers for FDL */
spc3.r_fdl_sap_list_ptr = SPC3_BUF_START + (dps2_buf_len>>3);
(*((UBYTE SPC3_PTR_ATTR*)((SPC3_ADTYP)(((UWORD)(spc3.r_fdl_sap_list_ptr
))<<3) + (SPC3_ADTYP)&spc3)) ) = 0xff;
dps2_buf_len += 8; /* 8 Byte durch leere FDL-Liste verbraucht */
/* DDB not supported */
spc3.r_len_ddbout_buf = 0;
spc3.r_ddbout_buf_ptr = 0;
spc3.r_len_ddb_prm_buf = 0;
spc3.r_ddb_prm_buf_ptr = 0;
}
return ret;
}
/* Ende dps2_buf_init() */
/*~
dps2_get_free_mem()
~*/
/*
+------------------------------------------------------------------------+
| Function: d p s 2 _ g e t _ f r e e _ m e m ( ) |
+------------------------------------------------------------------------+
| Description: |
| This function returns a pointer to the first free byte above the |
| DPS2-buffers. The count of free bytes is written to the pointer. |
+------------------------------------------------------------------------+
| Parameters: |
| -buf_len: pointer to len-variable |
| |
| Returncode: |
| -Pointer to first free byte |
+------------------------------------------------------------------------+
*/
UBYTE SPC3_PTR_ATTR* dps2_get_free_mem(WORD SPC3_DATA_ATTR *buf_len)
{
if(dps2_buf_len)
{
/* pointer to first free byte */
*buf_len = sizeof(SPC3) - (dps2_base_ptr - (UBYTE SPC3_PTR_ATTR*)&spc3
) - dps2_buf_len;
return dps2_base_ptr + dps2_buf_len;
}
else
{
/* not correctly initialized: Error */
*buf_len = 0;
return SPC3_NIL;
}
}
/* Ende dps2_free_mem() */
/*~
dps2_set_io_data_len()
~*/
/*
+------------------------------------------------------------------------+
| Function: d p s 2 _ s e t _ i o _ d a t a _ l e n ( ) |
+------------------------------------------------------------------------+
| Description: |
| The lens are checked against the initialization-lens. If they are |
| correct, the pointers and lens in the SPC3 are armed. |
+------------------------------------------------------------------------+
| Parameters: |
| -len_ptr: pointer to len-structure |
| |
| Returncode: |
| TRUE: ok |
| FALSE: len-mismatch |
+------------------------------------------------------------------------+
*/
UBYTE dps2_set_io_data_len(DPS2_IO_DATA_LEN SPC3_DATA_ATTR *len_ptr)
{
UBYTE ri_len, ro_len; /* real lens */
UBYTE ri_off; /* input-buffer-offset */
UBYTE i;
if(len_ptr->outp_data_len > 244)
{
return FALSE;
}
if(len_ptr->inp_data_len > 244)
{
return FALSE;
}
if((UWORD)len_ptr->inp_data_len + (UWORD)len_ptr->outp_data_len >
dps2_binit.din_dout_buf_len)
{
return FALSE;
}
/*-- lens correkt, arm buffers --*/
spc3.r_len_dout_buf = len_ptr->outp_data_len;
spc3.r_len_din_buf = len_ptr->inp_data_len;
ro_len = ((len_ptr->outp_data_len) + 7) >> 3;
ri_len = ((len_ptr->inp_data_len) + 7) >> 3;
for(i = 0; i < sizeof(spc3.r_dout_buf_ptr); i++)
{
spc3.r_dout_buf_ptr[i] = SPC3_BUF_START + ro_len * i;
}
ri_off = ro_len * sizeof(spc3.r_dout_buf_ptr);
for(i = 0; i < sizeof(spc3.r_din_buf_ptr); i++)
{
spc3.r_din_buf_ptr[i] = SPC3_BUF_START + ri_off + ri_len * i;
}
return TRUE;
}
/* Ende dps2_set_io_data_len */
/*~
dps2_cfg_data_ok()
~*/
/*
+------------------------------------------------------------------------+
| Function: d p s 2 _ c f g _ d a t a _ o k ( ) |
+------------------------------------------------------------------------+
| Description: |
| New config-data is marked as ok. |
+------------------------------------------------------------------------+
| Parameters: - |
| |
| Returncode: |
| UBYTE: DPS2_CFG_FINISHED: ok |
| DPS2_CFG_CONFLICT: data overridden while check |
+------------------------------------------------------------------------+
*/
UBYTE dps2_cfg_data_ok(void)
{
spc3.x1.w.mode_reg1_r = EN_CHG_CFG_BUFFER;
return spc3.user_cfg_data_ok;
}
/* Ende dps2_cfg_data_ok() */
/*~
dps2_cfg_data_update()
~*/
/*
+------------------------------------------------------------------------+
| Function: d p s 2 _ c f g _ d a t a _ u p d a t e ( ) |
+------------------------------------------------------------------------+
| Description: |
| see dps2_cfg_data_ok(), additional there are new cfg-data. |
+------------------------------------------------------------------------+
| Parameters: - |
| |
| Returncode: see dps2_cfg_data_ok() |
+------------------------------------------------------------------------+
*/
UBYTE dps2_cfg_data_update(void)
{
spc3.x1.w.mode_reg1_s = EN_CHG_CFG_BUFFER;
spc3.r_len_read_cfg_buf = spc3.r_len_cfg_buf;
return spc3.user_cfg_data_ok;
}
/* Ende dps2_cfg_data_update() */
/*~
dps2_cfg_data_not_ok()
~*/
/*
+------------------------------------------------------------------------+
| Function: d p s 2 _ c f g _ d a t a _ n o t _ o k ( ) |
+------------------------------------------------------------------------+
| Description: |
| See dps2_cfg_data_ok(), but config-data is not correct. |
+------------------------------------------------------------------------+
| Parameters: - |
| |
| Returncode: see dps2_cfg_data_ok() |
+------------------------------------------------------------------------+
*/
UBYTE dps2_cfg_data_not_ok(void)
{
spc3.x1.w.mode_reg1_r = EN_CHG_CFG_BUFFER;
return spc3.user_cfg_data_nok;
}
/* Ende dps2_cfg_data_not_ok() */
/*~
dps2_output_update_state()
~*/
/*
+------------------------------------------------------------------------+
| Function: d p s 2 _ o u t p u t _ u p d a t e _ s t a t e ( ) |
+------------------------------------------------------------------------+
| Description: |
| This function causes the output-update. The state is returned. |
+------------------------------------------------------------------------+
| Parameters: |
| -state_ptr: pointer to state-value |
| |
| Returncode: |
| void*: pointer to output-buffer |
+------------------------------------------------------------------------+
*/
void SPC3_PTR_ATTR* dps2_output_update_state(UBYTE SPC3_DATA_ATTR *state_ptr
)
{
UBYTE temp;
temp = spc3.x1.r.next_dout_buf_cmd;
*state_ptr = temp & (NEW_DOUT_BUF | DOUT_BUF_CLEARED);
return (void SPC3_PTR_ATTR*)
((((SPC3_ADTYP)(spc3.r_dout_buf_ptr[(temp & 0x03)-1]))<<3)\
+ (SPC3_ADTYP)&spc3);
}
/* Ende dps2_output_update_state() */
/*~
dps2_diag_update()
~*/
/*
+------------------------------------------------------------------------+
| Function: d p s 2 _ d i a g _ u p d a t e ( ) |
+------------------------------------------------------------------------+
| Description: |
| This function causes the diagnostic-update in the SPC3. |
+------------------------------------------------------------------------+
| Parameter: |
| |
| Returncode: |
| -pointer to new diagnostic-buffer, if available; else 0 |
+------------------------------------------------------------------------+
*/
void SPC3_PTR_ATTR* dps2_diag_update(void)
{
UBYTE temp;
temp = spc3.new_diag_buffer_cmd & 0x03;
switch(temp)
{
case 1: /* buffer with Index 0 */
{
return (void SPC3_PTR_ATTR*)((SPC3_ADTYP)(((UWORD)
spc3.r_diag_buf_ptr[0])<<3) + (SPC3_ADTYP)&spc3);
}
case 2: /* buffer with Index 1 */
{
return (void SPC3_PTR_ATTR*)((SPC3_ADTYP)(((UWORD)
spc3.r_diag_buf_ptr[1])<<3) + (SPC3_ADTYP)&spc3);
}
default:
{
/* no buffer */
return SPC3_NIL;
}
}
}
/* Ende dps2_diag_update() */
#ifdef _C166
#pragma public
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -