This patch adds support for PWM generation using CTIMER on MCXN devices.
Each CTIMER provides 4 PWM channels, channels sharing the same
CTIMER instance will have the same period settings, and the duty
cycle will be maintained if period is changed through one of the four
channels.
The period channel is automatically assigned and will be transferred
to one of the other available channels if that channel is used for PWM
generation, no glitches should be expected during the transition.
The patch also provides a sample PWM output configuration connected to
the on-board green LED which can be enabled through Kconfig.
Signed-off-by: Yilin Sun <imi415@imi.moe>
This patch adds support for hwtimer using MRT0 instance which simulates
4 independent timers. The frequency is fixed to AHB bus frequency and
not adjustable.
Signed-off-by: Yilin Sun <imi415@imi.moe>
为什么提交这份PR (why to submit this PR)
serial_v2驱动框架,rt_serial_tx_enable()函数,在 DMA阻塞发送(RT_DEVICE_FLAG_DMA_TX and RT_SERIAL_TX_BLOCKING) 的时候,使用rt_malloc分配了tx_fifo内存,但是并未对tx_fifo->rb.buffer_ptr指针进行初始化(rt_malloc不会自动初始化内存),因此可能导致buffer_ptr是一个随机指针。但是rt_serail_write()函数需要根据tx_fifo->rb.buffer_ptr是否为RT_NULL来判断是调用_serial_fifo_tx_blocking_nbuf()还是_serial_fifo_tx_blocking_buf()。
由于tx_fifo->rb.buffer_ptr可能是一个随机值(不一定为RT_NULL=0),导致RT_DEVICE_FLAG_DMA_TX and RT_SERIAL_TX_BLOCKING模式下调用了_serial_fifo_tx_blocking_buf(),但是rb没有真正开辟内存空间,导致内存异常
你的解决方案是什么 (what is your solution)
rt_serial_tx_enable(),在DMA阻塞发送分支下,对tx_fifo->rb.buffer_ptr进行初始化,赋值为RT_NULL。
1 - The current linker flags undefines `Reset_Handler' and uses `entry()' as
default entry point (specified by `-e'), which will cause a invalid reset
vector in the image without proper crt0 init assembly routine.
2 - The default startup files provided by NXP violate the crt0 assumption
that bss section will be filled with zero unless macro `__STARTUP_CLEAR_BSS'
is defined. This will cause RTT hook funtion pointers set to non-NULL values at
kernel start, thus successfully passes the `RT_nnnn_HOOK_CALL` checks
and jumps to an invalid pointer.
3 - The default heap size used by TCB and kernel objects are set by
linker file macros, which is 0x400 (1024 bytes). The size is too small
for main task and the allocation will fail before the first task being created.
This patch restores Reset_Handler as default reset vector and executes
entry by replacing __START from newlib, defines the
`__STARTUP_CLEAR_BSS` macro to forcibly zeroize the bss section to avoid
unexpected hard faults, set proper heap sizes based on the SRAM sizes.
Some unused compiler/linker flags are also removed or replaced to avoid
future confusion.
The heap sizes for different devices are:
* LPC55(S)69/LPC55(S)28: 64kB
* LPC55(S)06/LPC55(S)16/LPC55(S)36: 32kB
Signed-off-by: Yilin Sun <imi415@imi.moe>