首页 \ 问答 \ SPI协议程序(SPI Protocol Procedure)

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
更新时间:2023-04-14 12:04

最满意答案

您可以实现装饰器的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 ...
  • 您可以实现装饰器的Select元素,该元素可生成HTML以供选择,但未转义的值。 例如: class My_Select_Decorator extends Zend_Form_Decorator_Abstract { public function render($content) { $element = $this->getElement(); // Generate HTML markup return $markup; } } ...
  • 尝试将groupBy添加到您的查询中(未经测试) $select = $this->_db->select()->from('reviews') ->joinLeft('users', 'reviews.reviewer_id = users.id') ->joinLeft('websites', 'reviews.user_id = reviews.user_id') ...
  • 您需要为下拉选项提供显示值。 更改: $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继承的 ...
  • 使用您的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制作表单。 原因是,在使用表单时,将花费时间制作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 ...

相关文章

更多

最新问答

更多
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • 电脑高中毕业学习去哪里培训
  • 电脑系统专业就业状况如何啊?
  • IEnumerable linq表达式(IEnumerable linq expressions)
  • 如何在Spring测试中连接依赖关系(How to wire dependencies in Spring tests)
  • Solr可以在没有Lucene的情况下运行吗?(Can Solr run without Lucene?)
  • 如何保证Task在当前线程上同步运行?(How to guarantee that a Task runs synchronously on the current thread?)
  • 在保持每列的类的同时向数据框添加行(Adding row to data frame while maintaining the class of each column)
  • 的?(The ? marks in emacs/haskell and ghc mode)
  • 一个线程可以调用SuspendThread传递自己的线程ID吗?(Can a thread call SuspendThread passing its own thread ID?)
  • 延迟socket.io响应,并“警告 - websocket连接无效”(Delayed socket.io response, and “warn - websocket connection invalid”)
  • 悬停时的图像转换(Image transition on hover)
  • IIS 7.5仅显示homecontroller(IIS 7.5 only shows homecontroller)
  • 没有JavaScript的复选框“关闭”值(Checkbox 'off' value without JavaScript)
  • java分布式框架有哪些
  • Python:填写表单并点击按钮确认[关闭](Python: fill out a form and confirm with a button click [closed])
  • PHP将文件链接到根文件目录(PHP Linking Files to Root File Directory)
  • 我如何删除ListView中的项目?(How I can remove a item in my ListView?)
  • 您是否必须为TFS(云)中的每个BUG创建一个TASK以跟踪时间?(Do you have to create a TASK for every BUG in TFS (Cloud) to track time?)
  • typoscript TMENU ATagParams小写(typoscript TMENU ATagParams lowercase)
  • 武陟会计培训类的学校哪个好点?
  • 从链接中删除文本修饰(Remove text decoration from links)