Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3cccdba575 | |||
| b22f41e1b9 |
+119
-112
@@ -145,9 +145,9 @@ void cpg11_pulse_start(uint32_t hw_idx, pulse_gen_t *p_pulse_gen)
|
|||||||
nrf_gpiote_task_disable(pulse_gen_hw[hw_idx].gpiote_idx[2]);
|
nrf_gpiote_task_disable(pulse_gen_hw[hw_idx].gpiote_idx[2]);
|
||||||
nrf_gpiote_task_disable(pulse_gen_hw[hw_idx].gpiote_idx[3]);
|
nrf_gpiote_task_disable(pulse_gen_hw[hw_idx].gpiote_idx[3]);
|
||||||
|
|
||||||
nrf_gpiote_task_configure(pulse_gen_hw[hw_idx].gpiote_idx[0], p_pulse_gen->VBxH, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_HIGH);
|
nrf_gpiote_task_configure(pulse_gen_hw[hw_idx].gpiote_idx[0], p_pulse_gen->VAxH, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
|
||||||
nrf_gpiote_task_configure(pulse_gen_hw[hw_idx].gpiote_idx[1], p_pulse_gen->VBxL, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
|
nrf_gpiote_task_configure(pulse_gen_hw[hw_idx].gpiote_idx[1], p_pulse_gen->VBxL, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
|
||||||
nrf_gpiote_task_configure(pulse_gen_hw[hw_idx].gpiote_idx[2], p_pulse_gen->VAxH, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_HIGH);
|
nrf_gpiote_task_configure(pulse_gen_hw[hw_idx].gpiote_idx[2], p_pulse_gen->VBxH, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
|
||||||
nrf_gpiote_task_configure(pulse_gen_hw[hw_idx].gpiote_idx[3], p_pulse_gen->VAxL, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
|
nrf_gpiote_task_configure(pulse_gen_hw[hw_idx].gpiote_idx[3], p_pulse_gen->VAxL, NRF_GPIOTE_POLARITY_TOGGLE, NRF_GPIOTE_INITIAL_VALUE_LOW);
|
||||||
|
|
||||||
nrf_gpiote_task_enable(pulse_gen_hw[hw_idx].gpiote_idx[0]);
|
nrf_gpiote_task_enable(pulse_gen_hw[hw_idx].gpiote_idx[0]);
|
||||||
@@ -244,139 +244,146 @@ void cpg11_pulse_init(uint32_t hw_idx, pulse_gen_t *p_pulse_gen, uint32_t len)
|
|||||||
|
|
||||||
void cpg_pulse_default_demo_ext(void)
|
void cpg_pulse_default_demo_ext(void)
|
||||||
{
|
{
|
||||||
uint32_t pulse_gen_numb = 2;
|
bool e1 = 1;
|
||||||
|
bool e2 = 1;
|
||||||
|
bool e3 = 1;
|
||||||
|
bool e4 = 1;
|
||||||
|
pulse_gen_t p_pulse_genA[2];
|
||||||
|
pulse_gen_t p_pulse_genB[2];
|
||||||
|
|
||||||
pulse_gen_t *p_pulse_genA = pvPortMalloc(sizeof(pulse_gen_t) * pulse_gen_numb);
|
p_pulse_genA[0] = (pulse_gen_t) {
|
||||||
pulse_gen_t *p_pulse_genB = pvPortMalloc(sizeof(pulse_gen_t) * pulse_gen_numb);
|
.VBxH = VB1H_PIN,
|
||||||
|
.VBxL = VB1L_PIN,
|
||||||
|
.VAxH = VA1H_PIN,
|
||||||
|
.VAxL = VA1L_PIN,
|
||||||
|
.point_us[0] = 1,
|
||||||
|
.point_us[1] = 50,
|
||||||
|
.point_us[2] = 1,
|
||||||
|
.point_us[3] = 0,
|
||||||
|
.point_us[4] = 1,
|
||||||
|
.point_us[5] = 50,
|
||||||
|
.point_us[6] = 1,
|
||||||
|
.idle_us = 1000,
|
||||||
|
.pulse_cnt = UINT32_MAX,
|
||||||
|
.pulse_id = PULSE_ID_A,
|
||||||
|
};
|
||||||
|
|
||||||
memset(p_pulse_genA, 0x00, sizeof(pulse_gen_t) * pulse_gen_numb);
|
p_pulse_genA[1] = (pulse_gen_t) {
|
||||||
memset(p_pulse_genB, 0x00, sizeof(pulse_gen_t) * pulse_gen_numb);
|
.VBxH = VB2H_PIN,
|
||||||
|
.VBxL = VB2L_PIN,
|
||||||
|
.VAxH = VA2H_PIN,
|
||||||
|
.VAxL = VA2L_PIN,
|
||||||
|
.point_us[0] = 1,
|
||||||
|
.point_us[1] = 50,
|
||||||
|
.point_us[2] = 1,
|
||||||
|
.point_us[3] = 0,
|
||||||
|
.point_us[4] = 1,
|
||||||
|
.point_us[5] = 50,
|
||||||
|
.point_us[6] = 1,
|
||||||
|
.idle_us = 1000,
|
||||||
|
.pulse_cnt = UINT32_MAX,
|
||||||
|
.pulse_id = PULSE_ID_B,
|
||||||
|
};
|
||||||
|
|
||||||
if (pulse_gen_numb > 0)
|
p_pulse_genB[0] = (pulse_gen_t) {
|
||||||
|
.VBxH = VB3H_PIN,
|
||||||
|
.VBxL = VB3L_PIN,
|
||||||
|
.VAxH = VA3H_PIN,
|
||||||
|
.VAxL = VA3L_PIN,
|
||||||
|
.point_us[0] = 1,
|
||||||
|
.point_us[1] = 50,
|
||||||
|
.point_us[2] = 1,
|
||||||
|
.point_us[3] = 0,
|
||||||
|
.point_us[4] = 1,
|
||||||
|
.point_us[5] = 50,
|
||||||
|
.point_us[6] = 1,
|
||||||
|
.idle_us = 1000,
|
||||||
|
.pulse_cnt = UINT32_MAX,
|
||||||
|
.pulse_id = PULSE_ID_C,
|
||||||
|
};
|
||||||
|
|
||||||
|
p_pulse_genB[1] = (pulse_gen_t) {
|
||||||
|
.VBxH = VB4H_PIN,
|
||||||
|
.VBxL = VB4L_PIN,
|
||||||
|
.VAxH = VA4H_PIN,
|
||||||
|
.VAxL = VA4L_PIN,
|
||||||
|
.point_us[0] = 1,
|
||||||
|
.point_us[1] = 50,
|
||||||
|
.point_us[2] = 1,
|
||||||
|
.point_us[3] = 0,
|
||||||
|
.point_us[4] = 1,
|
||||||
|
.point_us[5] = 50,
|
||||||
|
.point_us[6] = 1,
|
||||||
|
.idle_us = 1000,
|
||||||
|
.pulse_cnt = UINT32_MAX,
|
||||||
|
.pulse_id = PULSE_ID_B,
|
||||||
|
};
|
||||||
|
|
||||||
|
if(e1)
|
||||||
{
|
{
|
||||||
p_pulse_genA[0] = (pulse_gen_t) {
|
nrf_gpio_pin_clear(p_pulse_genA[0].VBxL);
|
||||||
.VBxH = VB1H_PIN,
|
nrf_gpio_pin_clear(p_pulse_genA[0].VBxH);
|
||||||
.VBxL = VB1L_PIN,
|
nrf_gpio_pin_clear(p_pulse_genA[0].VAxL);
|
||||||
.VAxH = VA1H_PIN,
|
nrf_gpio_pin_clear(p_pulse_genA[0].VAxH);
|
||||||
.VAxL = VA1L_PIN,
|
|
||||||
.point_us[0] = 1,
|
|
||||||
.point_us[1] = 50,
|
|
||||||
.point_us[2] = 1,
|
|
||||||
.point_us[3] = 0,
|
|
||||||
.point_us[4] = 1,
|
|
||||||
.point_us[5] = 50,
|
|
||||||
.point_us[6] = 1,
|
|
||||||
.idle_us = 1000,
|
|
||||||
.pulse_cnt = UINT32_MAX,
|
|
||||||
.pulse_id = 0,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pulse_gen_numb > 1)
|
if(e2)
|
||||||
{
|
{
|
||||||
p_pulse_genA[1] = (pulse_gen_t) {
|
nrf_gpio_pin_clear(p_pulse_genA[1].VBxL);
|
||||||
.VBxH = VB2H_PIN,
|
nrf_gpio_pin_clear(p_pulse_genA[1].VBxH);
|
||||||
.VBxL = VB2L_PIN,
|
nrf_gpio_pin_clear(p_pulse_genA[1].VAxL);
|
||||||
.VAxH = VA2H_PIN,
|
nrf_gpio_pin_clear(p_pulse_genA[1].VAxH);
|
||||||
.VAxL = VA2L_PIN,
|
|
||||||
.point_us[0] = 1,
|
|
||||||
.point_us[1] = 50,
|
|
||||||
.point_us[2] = 1,
|
|
||||||
.point_us[3] = 0,
|
|
||||||
.point_us[4] = 1,
|
|
||||||
.point_us[5] = 50,
|
|
||||||
.point_us[6] = 1,
|
|
||||||
.idle_us = 1000,
|
|
||||||
.pulse_cnt = UINT32_MAX,
|
|
||||||
.pulse_id = 1,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pulse_gen_numb > 0)
|
if(e3)
|
||||||
{
|
{
|
||||||
p_pulse_genB[0] = (pulse_gen_t) {
|
nrf_gpio_pin_clear(p_pulse_genB[0].VBxL);
|
||||||
.VBxH = VB3H_PIN,
|
nrf_gpio_pin_clear(p_pulse_genB[0].VBxH);
|
||||||
.VBxL = VB3L_PIN,
|
nrf_gpio_pin_clear(p_pulse_genB[0].VAxL);
|
||||||
.VAxH = VA3H_PIN,
|
nrf_gpio_pin_clear(p_pulse_genB[0].VAxH);
|
||||||
.VAxL = VA3L_PIN,
|
|
||||||
.point_us[0] = 1,
|
|
||||||
.point_us[1] = 50,
|
|
||||||
.point_us[2] = 1,
|
|
||||||
.point_us[3] = 0,
|
|
||||||
.point_us[4] = 1,
|
|
||||||
.point_us[5] = 50,
|
|
||||||
.point_us[6] = 1,
|
|
||||||
.idle_us = 1000,
|
|
||||||
.pulse_cnt = UINT32_MAX,
|
|
||||||
.pulse_id = 2,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pulse_gen_numb > 1)
|
if(e4)
|
||||||
{
|
{
|
||||||
p_pulse_genB[1] = (pulse_gen_t) {
|
nrf_gpio_pin_clear(p_pulse_genB[1].VBxL);
|
||||||
.VBxH = VB4H_PIN,
|
nrf_gpio_pin_clear(p_pulse_genB[1].VBxH);
|
||||||
.VBxL = VB4L_PIN,
|
nrf_gpio_pin_clear(p_pulse_genB[1].VAxL);
|
||||||
.VAxH = VA4H_PIN,
|
nrf_gpio_pin_clear(p_pulse_genB[1].VAxH);
|
||||||
.VAxL = VA4L_PIN,
|
|
||||||
.point_us[0] = 1,
|
|
||||||
.point_us[1] = 50,
|
|
||||||
.point_us[2] = 1,
|
|
||||||
.point_us[3] = 0,
|
|
||||||
.point_us[4] = 1,
|
|
||||||
.point_us[5] = 50,
|
|
||||||
.point_us[6] = 1,
|
|
||||||
.idle_us = 1000,
|
|
||||||
.pulse_cnt = UINT32_MAX,
|
|
||||||
.pulse_id = 3,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = 0; i < pulse_gen_numb; i++)
|
|
||||||
|
if (e1 && e2)
|
||||||
{
|
{
|
||||||
nrf_gpio_pin_clear(p_pulse_genA[i].VBxL);
|
cpg11_pulse_init(0, p_pulse_genA, 2);
|
||||||
nrf_gpio_pin_set(p_pulse_genA[i].VBxH);
|
cpg11_pulse_start(0, p_pulse_genA);
|
||||||
nrf_gpio_pin_clear(p_pulse_genA[i].VAxL);
|
}
|
||||||
nrf_gpio_pin_set(p_pulse_genA[i].VAxH);
|
else if (e1 && e2==0)
|
||||||
|
{
|
||||||
|
cpg11_pulse_init(0, p_pulse_genA, 1);
|
||||||
|
cpg11_pulse_start(0, p_pulse_genA);
|
||||||
|
}
|
||||||
|
else if (e2 && e1==0)
|
||||||
|
{
|
||||||
|
cpg11_pulse_init(0, &p_pulse_genA[1], 1);
|
||||||
|
cpg11_pulse_start(0, &p_pulse_genA[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (e3 && e4)
|
||||||
for (uint32_t i = 0; i < pulse_gen_numb; i++)
|
|
||||||
{
|
{
|
||||||
nrf_gpio_pin_clear(p_pulse_genB[i].VBxL);
|
cpg11_pulse_init(1, p_pulse_genB, 2);
|
||||||
nrf_gpio_pin_set(p_pulse_genB[i].VBxH);
|
cpg11_pulse_start(1, p_pulse_genB);
|
||||||
nrf_gpio_pin_clear(p_pulse_genB[i].VAxL);
|
|
||||||
nrf_gpio_pin_set(p_pulse_genB[i].VAxH);
|
|
||||||
}
|
}
|
||||||
*/
|
else if (e3 && e4==0)
|
||||||
|
|
||||||
cpg11_pulse_init(0, p_pulse_genA, pulse_gen_numb);
|
|
||||||
|
|
||||||
// cpg11_pulse_init(1, p_pulse_genB, pulse_gen_numb);
|
|
||||||
|
|
||||||
cpg11_pulse_start(0, p_pulse_genA);
|
|
||||||
|
|
||||||
// cpg11_pulse_start(1, p_pulse_genB);
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
{
|
||||||
vTaskDelay(10);
|
cpg11_pulse_init(1, p_pulse_genB, 1);
|
||||||
cpg11_pulse_suspend_by_pulse_id(p_pulse_genA[0].pulse_id);
|
cpg11_pulse_start(1, p_pulse_genB);
|
||||||
vTaskDelay(10);
|
|
||||||
cpg11_pulse_resume_by_pulse_id(p_pulse_genA[0].pulse_id);
|
|
||||||
}
|
}
|
||||||
// cpg11_pulse_suspend_by_pulse_id(p_pulse_gen[0].pulse_id);
|
else if (e4 && e3==0)
|
||||||
// cpg11_pulse_suspend_by_pulse_id(p_pulse_gen[1].pulse_id);
|
|
||||||
// cpg11_pulse_suspend_by_pulse_id(p_pulse_gen[2].pulse_id);
|
|
||||||
// cpg11_pulse_suspend_by_pulse_id(p_pulse_gen[3].pulse_id);
|
|
||||||
// cpg11_pulse_suspend_by_pulse_id(p_pulse_gen[4].pulse_id);
|
|
||||||
|
|
||||||
vPortFree(p_pulse_genA);
|
|
||||||
vPortFree(p_pulse_genB);
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
{
|
||||||
|
cpg11_pulse_init(1, &p_pulse_genB[1], 1);
|
||||||
|
cpg11_pulse_start(1, &p_pulse_genB[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpg11_io_init(void)
|
void cpg11_io_init(void)
|
||||||
@@ -476,7 +483,7 @@ void cpg11_io_init(void)
|
|||||||
pulse_gen_hw[i].private.p_pulse_gen[1].VBxL = 0xFFFFFFFF;
|
pulse_gen_hw[i].private.p_pulse_gen[1].VBxL = 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
// cpg_pulse_default_demo_ext();
|
cpg_pulse_default_demo_ext();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user