开源改变世界

Config.h 中不一致的“OEM”指令 #65

推推 grbl 3年前 (2023-02-10) 199次浏览
关闭
J-Dunn 打开了这个问题 2021 年 5 月 23 日 · 3条评论
关闭

Config.h 中不一致的“OEM”指令#65

J-Dunn 打开了这个问题 2021 年 5 月 23 日 · 3条评论

评论

Config.h 中不一致的“OEM”指令 #65
J-邓恩 评论了 2021 年 5 月 23 日  

配置.h:


// If doing so, simply comment out these two defines and see instructions below.
#define DEFAULTS_GENERIC

// Serial baud rate
#define BAUD_RATE   115200
//#define BAUD_RATE 230400

没有“两个定义”,只有一个。


   Instructions: Paste the cpu_map and default setting definitions below without an enclosing
   #ifdef. Comment out the CPU_MAP_xxx and DEFAULT_xxx defines at the top of this file, and
   the compiler will ignore the contents of defaults.h and cpu_map.h and use the definitions
   below.

没有 CPU_MAP_xxx 定义。

grbl/defaults.c :


#ifdef DEFAULTS_GENERIC
    // Grbl generic default settings. Should work across different machines.

这似乎已经改变,说明不再一致。


System.c :

    uint8_t pin = ((GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0)<<CONTROL_RESET_BIT) |
                   (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1)<<CONTROL_FEED_HOLD_BIT) |
                   (GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_4)<<CONTROL_CYCLE_START_BIT) |
                   (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_8)<<CONTROL_SAFETY_DOOR_BIT));

IO 引脚的 cpu 映射是否有任何集中点,或者我们是否必须浏览所有像这样的部分的 c 代码以识别和设置它现在是如何在 stm32F4 芯片上设置的?

顺便说一句,我意识到在 stm32 和 avr 上使用和配置引脚的方式发生了根本性的变化,我已经在这个 h/w 上使用了不同的 GRBL 端口,但是如果整体结构保持不变就好了可以快速访问该端口使用情况。

我很想测试这个端口,因为我想摆脱对 eclipse 和庞大而缓慢的 a6 工作台的依赖。我喜欢 Makefile 方法。

感谢您的任何澄清。

Config.h 中不一致的“OEM”指令 #65

目前没有用于 cpu 映射的集中点。您需要一个完整的抽象层来实现此功能。现在有必要修改所有涉及的文件。

Config.h 中不一致的“OEM”指令 #65
作者
J-邓恩 评论了 2021 年 5 月 24 日  

谢谢。我的意思不是完整的 HAL,只是所有这些设置都在同一个文件中,就像它们在 GRBL 上一样。然后你只需要去一个地方查看所有需要的值以及它们配置的引脚。

在我原来的 GRBL 0.9x 上,这一切都在文件 cpu_map.h 中

Config.h 中不一致的“OEM”指令 #65
作者
J-邓恩 评论了 2021 年 5 月 25 日  

我在 nut_bolt.c 中定义了这些实用函数,以帮助清理 stm32 上的代码:



void set_as_output(GPIO_TypeDef* port, uint32_t pin)
{
  GPIO_InitTypeDef GPIO_InitStructure;

  GPIO_InitStructure.GPIO_Pin = pin;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(port, &GPIO_InitStructure);
}

void set_as_input(GPIO_TypeDef* port, uint32_t pin)
{
  GPIO_InitTypeDef GPIO_InitStructure;

  GPIO_InitStructure.GPIO_Pin = pin;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_Init(port, &GPIO_InitStructure);
}

void set_as_AF(GPIO_TypeDef* port, uint32_t pin)    // connect pins to alternate function
{
  GPIO_InitTypeDef GPIO_InitStructure;

  GPIO_InitStructure.GPIO_Pin = pin;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_Init(port, &GPIO_InitStructure);
}

然后例如在 stepper.c 中:

set_as_output(STEP_EN);

grbl/cpu_map/cpu_map_stm32f411_nucleos.h:180:

#define STEP_EN GPIOA,GPIO_Pin_9 // D8

所有硬件细节都被提取到一个中央文件中,以便于参考,并且不会影响功能代码的可读性。
如果您需要移动大头针,让生活变得更轻松。