SPI协议程序(SPI Protocol Procedure)
嘿,我正在将ADS1292用于我自己的项目,而我自己也对SPI协议感到困惑。
我在互联网上找到了一些代码,我发现它一次发送和接收。
例如,我想向从设备发送0xFF。
然后它首先发送数据并等待接收。
当接收数据时,它发送一个虚拟字节然后接收。
有人请解释他们为什么这样做?
uint8_t sEE_ReadByte(void) { return (sEE_SendByte(sEE_DUMMY_BYTE)); } uint8_t sEE_SendByte(uint8_t byte) { /*!< Loop while DR register in not empty */ while (SPI_I2S_GetFlagStatus(sEE_SPI, SPI_I2S_FLAG_TXE) == RESET); /*!< Send byte through the SPI peripheral */ SPI_SendData(sEE_SPI, byte); /*!< Wait to receive a byte => I do not understand this point*/ while (SPI_I2S_GetFlagStatus(sEE_SPI, SPI_I2S_FLAG_RXNE) == RESET); /*!< Return the byte read from the SPI bus */ return (uint8_t)SPI_ReceiveData(sEE_SPI); }
hey i am using ADS1292 for my own project, and myself is confused with SPI protocol.
i found some code on the internet and i found it sends and receive at one time.
for example, i want to send 0xFF to slave device.
then it sends the data first and wait for a receive.
And when receiving data, it sends a dummy byte and then receive.
Anyone please explain why they do this?
uint8_t sEE_ReadByte(void) { return (sEE_SendByte(sEE_DUMMY_BYTE)); } uint8_t sEE_SendByte(uint8_t byte) { /*!< Loop while DR register in not empty */ while (SPI_I2S_GetFlagStatus(sEE_SPI, SPI_I2S_FLAG_TXE) == RESET); /*!< Send byte through the SPI peripheral */ SPI_SendData(sEE_SPI, byte); /*!< Wait to receive a byte => I do not understand this point*/ while (SPI_I2S_GetFlagStatus(sEE_SPI, SPI_I2S_FLAG_RXNE) == RESET); /*!< Return the byte read from the SPI bus */ return (uint8_t)SPI_ReceiveData(sEE_SPI); }
原文:https://stackoverflow.com/questions/36492711
最满意答案
您可以实现装饰器的Select元素,该元素可生成HTML以供选择,但未转义的值。 例如:
class My_Select_Decorator extends Zend_Form_Decorator_Abstract { public function render($content) { $element = $this->getElement(); // Generate HTML markup return $markup; } }
请参阅这些文章以获取更多信息:
http://weierophinney.net/matthew/archives/212-The-simplest-Zend_Form-decorator.html
http://codeutopia.net/blog/2008/08/07/zend_form-decorator-tips/
You can implement your decorator for Select element that generates HTML for select with unescaped value. For example:
class My_Select_Decorator extends Zend_Form_Decorator_Abstract { public function render($content) { $element = $this->getElement(); // Generate HTML markup return $markup; } }
Refer to these articles for more information:
http://weierophinney.net/matthew/archives/212-The-simplest-Zend_Form-decorator.html
http://codeutopia.net/blog/2008/08/07/zend_form-decorator-tips/
相关问答
更多-
听起来像magic_quote_gpc已打开。 您可以使用get_magic_quotes_gpc来检查是否启用了魔法语句 echo (get_magic_quotes_gpc()) ? 'Magic qoutes Enabled' : "Magic qoutes Disabled"; 我强烈建议禁用魔术引号 。 试试下面的.htaccess文件指令: php_value magic_quotes_gpc Off 或者在你的php.ini中 magic_quotes_gpc = Off Sounds ...
-
如何防止在Zend Form上转义选择Zend Framework(How to prevent escaping on Zend Form Select : Zend Framework)[2023-01-31]
您可以实现装饰器的Select元素,该元素可生成HTML以供选择,但未转义的值。 例如: class My_Select_Decorator extends Zend_Form_Decorator_Abstract { public function render($content) { $element = $this->getElement(); // Generate HTML markup return $markup; } } ... -
Zend Framework加入(Zend Framework join)[2023-10-30]
尝试将groupBy添加到您的查询中(未经测试) $select = $this->_db->select()->from('reviews') ->joinLeft('users', 'reviews.reviewer_id = users.id') ->joinLeft('websites', 'reviews.user_id = reviews.user_id') ... -
zend框架1如何将表单从其他表中选择(zend framework 1 how to set a form fiels as select from another table)[2022-05-03]
您需要为下拉选项提供显示值。 更改: $id_magasin->addMultiOption($d->id_magasin); 至 $id_magasin->addMultiOption($d->id_magasin, $d->id_magasin); 在选择中显示ID。 另外,我不知道在Application_Model_DbTable_Magasin中是否有函数“getAll()”,或者如果您正在扩展Zend_Db_Table_Abstract,但由Zend_Db_Table_Abstract继承的 ... -
Zend Framework 2中的表单(Form in Zend Framework 2)[2022-09-07]
使用您的html在login.phtml中创建一个表单。 对于登录身份验证,您必须在Controller中获取所请求的帖子表单数据(用户名和密码),并在提交表单时使用您的数据库数据检查凭据。 在这里,您必须为登录表单实现客户端验证。 Create a form in your login.phtml with your html. For Login authentication, you have to get the requested post form data (username & passwo ... -
添加$this->setTranslator(new Zend_Translate_Adapter_Array(array())); 在表格的开头。 这将覆盖默认翻译器,因为新的翻译器是空的,所以它不会翻译任何内容。 The Zend_Form_Element_Multi have this: if ($this->translatorIsDisabled()) { return false; } And there exist this method on Zend_Form_Element p ...
-
尝试, $this->addElement('MultiCheckbox', 'element-name', array( 'label' => 'Multiple Checkboxex', 'class'=>'example-class', )); Try, $this->addElement('MultiCheckbox', 'element-name', array( ...
-
你可以扩展Zend_Form。 Zend表单不是逻辑的好地方,只是表单表示。 因此,使用控制器中的模型加载所有需要的元素,并将它们作为参数传递给构造函数中的表单。 You could extend Zend_Form. Zend form is not good place for logic, only form representation. So, Load all needed elements using model in controller and pass them to the form ...
-
zend框架中的表单装饰器(form decorators in zend framework)[2022-02-08]
好吧,我的意见是尝试使用Zend Form制作表单。 原因是,在使用表单时,将花费时间制作Zend_Forms,设置装饰器,自定义元素或创建自己的元素。 使用Zend Form,您可以非常简单直接地验证表单,过滤字段内容,管理错误消息,翻译错误消息等。此外,一旦您花时间编写自己的或自定义现有装饰器,表单视图助手,表单元素,在下一个ZF项目中使用它们并使用它们将非常容易。 所以在我看来,从长远来看使用Zend_Form会节省你的时间,即使在开始时看起来使用Zend_Form会导致比不使用它们更麻烦和麻烦。 但 ... -
设置它的最佳位置是公共函数loadDefaultDecorators() 例如像这样: class ExampleForm extends Core_Form { public function init() { //Example Field $example = new Zend_Form_Element_Hidden('example'); $this->addElement($exampl ...