forked from arduino/ArduinoCore-renesas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved AGT that generates ethernet clock to timer to EthernetClock fro…
…m variant.cpp
- Loading branch information
1 parent
2ef2b3a
commit 470f8f3
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include "EthernetClock.h" | ||
|
||
|
||
|
||
EthernetClock::EthernetClock() { | ||
pinPeripheral(ETHERNET_CLK_PIN, (uint32_t) (IOPORT_CFG_PERIPHERAL_PIN | IOPORT_PERIPHERAL_AGT)); | ||
|
||
TIMER_ETHERNET_extend.count_source = AGT_CLOCK_PCLKB; | ||
TIMER_ETHERNET_extend.agto = AGT_PIN_CFG_START_LEVEL_LOW; | ||
TIMER_ETHERNET_extend.agtoab_settings_b.agtoa = AGT_PIN_CFG_DISABLED; | ||
TIMER_ETHERNET_extend.agtoab_settings_b.agtob = AGT_PIN_CFG_DISABLED; | ||
TIMER_ETHERNET_extend.measurement_mode = AGT_MEASURE_DISABLED; | ||
TIMER_ETHERNET_extend.agtio_filter = AGT_AGTIO_FILTER_NONE; | ||
TIMER_ETHERNET_extend.enable_pin = AGT_ENABLE_PIN_NOT_USED; | ||
TIMER_ETHERNET_extend.trigger_edge = AGT_TRIGGER_EDGE_RISING; | ||
|
||
TIMER_ETHERNET_cfg.mode = TIMER_MODE_PERIODIC; | ||
TIMER_ETHERNET_cfg.period_counts = (uint32_t) 0x1; | ||
TIMER_ETHERNET_cfg.duty_cycle_counts = 0x00; | ||
TIMER_ETHERNET_cfg.source_div = (timer_source_div_t) 0; | ||
TIMER_ETHERNET_cfg.channel = AGT_TIMER_CHANNEL; | ||
TIMER_ETHERNET_cfg.p_callback = NULL; | ||
TIMER_ETHERNET_cfg.p_context = NULL; | ||
TIMER_ETHERNET_cfg.p_extend = &TIMER_ETHERNET_extend; | ||
TIMER_ETHERNET_cfg.cycle_end_ipl = (BSP_IRQ_DISABLED); | ||
TIMER_ETHERNET_cfg.cycle_end_irq = FSP_INVALID_VECTOR; | ||
} | ||
|
||
EthernetClock::~EthernetClock() { | ||
delete this; | ||
} | ||
|
||
fsp_err_t EthernetClock::start() { | ||
|
||
|
||
fsp_err_t err = R_AGT_Open(&TIMER_ETHERNET_ctrl,&TIMER_ETHERNET_cfg); | ||
if (err != FSP_SUCCESS) { | ||
return err; | ||
} | ||
err = R_AGT_Enable(&TIMER_ETHERNET_ctrl); | ||
if (err != FSP_SUCCESS) { | ||
return err; | ||
} | ||
err = R_AGT_Start(&TIMER_ETHERNET_ctrl); | ||
if (err != FSP_SUCCESS) { | ||
return err; | ||
} | ||
|
||
FspTimer::set_timer_is_used(AGT_TIMER, AGT_TIMER_CHANNEL); | ||
return err; | ||
|
||
} | ||
|
||
fsp_err_t EthernetClock::stop() { | ||
fsp_err_t err = R_AGT_Stop(&TIMER_ETHERNET_ctrl); | ||
if (err != FSP_SUCCESS) { | ||
return err; | ||
} else { | ||
err = R_AGT_Close(&TIMER_ETHERNET_ctrl); | ||
if (err != FSP_SUCCESS) { | ||
return err; | ||
} else { | ||
err = R_AGT_Disable(&TIMER_ETHERNET_ctrl); | ||
if (err != FSP_SUCCESS) { | ||
return err; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
#ifndef ETHERNET_CLOCK_H | ||
#define ETHERNET_CLOCK_H | ||
|
||
|
||
#include "FspTimer.h" | ||
|
||
#define AGT_TIMER_CHANNEL 3 | ||
#define ETHERNET_CLK_PIN BSP_IO_PORT_06_PIN_00 | ||
|
||
|
||
class EthernetClock { | ||
public: | ||
static fsp_err_t start(); | ||
static fsp_err_t stop(); | ||
|
||
private: | ||
static agt_instance_ctrl_t TIMER_ETHERNET_ctrl; | ||
static agt_extended_cfg_t TIMER_ETHERNET_extend; | ||
static timer_cfg_t TIMER_ETHERNET_cfg; | ||
}; | ||
|
||
#endif |