Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed two issue of variable not being initialized which could cause wrong results #1985

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hardware/chip/haas1000/csi/pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ static int pwm_csi_init(void)
static aos_pwm_csi_t pwm_csi_dev[CONFIG_PWM_NUM];
int i;
for (i = 0; i < CONFIG_PWM_NUM; i++) {
ret = csi_pwm_init(&(pwm_csi_dev[i].csi_pwm), idx);
pwm_csi_dev[i].csi_pwm.dev.idx |= (i);
if (ret != CSI_OK) {
return ret;
Expand Down
11 changes: 8 additions & 3 deletions hardware/chip/rtl872xd/aos_adapter/pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static const aos_pwm_ops_t rtl872xd_pwm_ops = {

static int rtl872xd_pwm_init(void)
{
int ret;
int ret = 0;
static rtl872xd_pwm_t pwm_dev[CONFIG_PWM_NUM];
int idx = 0, i;
RTIM_TimeBaseInitTypeDef TIM_InitStruct;
Expand All @@ -216,8 +216,13 @@ static int rtl872xd_pwm_init(void)
RTIM_TimeBaseInit(RTL872xD_PWM_TIM[idx], &TIM_InitStruct, TIMER5_IRQ, NULL, (u32)&TIM_InitStruct);
RTIM_Cmd(RTL872xD_PWM_TIM[idx], ENABLE);
for (i = 0; i < CONFIG_PWM_NUM; i++) {
pwm_dev[i].priv = (TIM_CCInitTypeDef *)malloc(sizeof(TIM_CCInitTypeDef));
pwm_dev[i].idx = idx << BIT_PWM_TIM_IDX_SHIFT;
if (!pwm_dev[i] || IDX != 0) {
ret = -1;
}
else {
pwm_dev[i].priv = (TIM_CCInitTypeDef *)malloc(sizeof(TIM_CCInitTypeDef));
pwm_dev[i].idx = idx << BIT_PWM_TIM_IDX_SHIFT;
}
pwm_dev[i].idx |= (i) & (~BIT_PWM_TIM_IDX_FLAG);
if (ret != 0) {
return ret;
Expand Down