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

Added support for SAMG55 #1550

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
b407807
* Base Commit for SAMG55J19. No errors and no implementations.
akhilpanayamparambil Nov 18, 2015
d87f437
* Added gpio files.
akhilpanayamparambil Nov 18, 2015
ec95331
* Added pinmap files.
akhilpanayamparambil Nov 18, 2015
c71252f
* Base commit for usticker implementation.
akhilpanayamparambil Nov 19, 2015
148f09a
* Added gcc_arm export functionality
akhilpanayamparambil Nov 20, 2015
5d9a571
* added files for usticker.
akhilpanayamparambil Nov 23, 2015
42d5d47
* GPIO IRQ base commit.
akhilpanayamparambil Nov 23, 2015
653ebe8
* updated with changes in gpio irq driver.
akhilpanayamparambil Nov 24, 2015
a029fa3
* Reverted back unexpected commit in SAM0 gpio driver.
akhilpanayamparambil Nov 24, 2015
0eb3001
* updated gpio_irq driver.
akhilpanayamparambil Nov 25, 2015
c8e8e08
* correction in gpio and gpio_irq drivers.
akhilpanayamparambil Nov 25, 2015
0e3b8cb
* base commit for peripheralpins for usart.
akhilpanayamparambil Nov 26, 2015
8fb7b06
* updated serial apis.
akhilpanayamparambil Nov 27, 2015
c7dcd52
* updated serial apis and test.
akhilpanayamparambil Nov 28, 2015
b0ff5c1
* update serial apis for asynch apis.
akhilpanayamparambil Nov 28, 2015
ca7808a
* updated peripheral pins for i2c and spi.
akhilpanayamparambil Nov 30, 2015
511be0c
* Base commit for low power ticker implementation.
akhilpanayamparambil Nov 30, 2015
e37d2db
* base commit for port apis.
akhilpanayamparambil Dec 1, 2015
ce5416e
* Added test support for port.
akhilpanayamparambil Dec 1, 2015
0b61de3
* base commit for sleep apis.
akhilpanayamparambil Dec 2, 2015
843dd3b
* Base commit for spi.
akhilpanayamparambil Dec 3, 2015
0ba8db4
* updated with corrections in gpio irq.
akhilpanayamparambil Dec 10, 2015
ccc864d
* updated with corrections for unexpected board reset.
akhilpanayamparambil Dec 10, 2015
91462f3
* updated sleep api for deepsleep.
akhilpanayamparambil Dec 11, 2015
42b3cad
* updated serial apis.
akhilpanayamparambil Dec 15, 2015
a02c23e
Added uc_ticker and SPI api implementations
Dec 18, 2015
02d8c99
Removed unused SPI pin map
Dec 18, 2015
1e2acba
Updated review feedback
Dec 21, 2015
c7cca1e
* implemented lpticker with TC module.
akhilpanayamparambil Dec 21, 2015
1b8b376
* Base commit for AnalogueIn apis.
akhilpanayamparambil Dec 23, 2015
6a61fc9
* RTC apis base commit without implementation.
akhilpanayamparambil Dec 23, 2015
c36234d
* Updated with corrections in lpticker implementations.
akhilpanayamparambil Dec 23, 2015
438f845
* Added implementation for rtc apis.
akhilpanayamparambil Jan 5, 2016
b74a991
* updated with implementations for pwm.
akhilpanayamparambil Jan 12, 2016
6d1fe4b
Added I2C support
Jan 13, 2016
792f567
* removed setvector usage from usticker and lpticker implementations
akhilpanayamparambil Jan 13, 2016
4ad240f
* Removed unwanted .o and .d files.
akhilpanayamparambil Jan 19, 2016
db2636f
* Removed unwanted headers file inclusion.
akhilpanayamparambil Jan 20, 2016
b67f5f7
* Updated ADC with 16 bit mode initialization and code refinements.
akhilpanayamparambil Jan 27, 2016
14f3f3b
Updated I2C review feedback and fixed style
Feb 16, 2016
3de8a1d
Fixed merge conflicts
Feb 16, 2016
d3b5990
Updated target name for SAMG55
Feb 16, 2016
a0edad3
Merge pull request #1 from Parthasarathy/atmel
Parthasarathy Feb 16, 2016
df374b1
* Added Test Support for I2C with AT30TSE75X and Added Support for SA…
akhilpanayamparambil Mar 4, 2016
e22b980
* Added Test Support for I2C with AT30TSE75X and Added Support for SA…
akhilpanayamparambil Mar 4, 2016
feca68d
Used NVIC_SetVector for interrupt callback
Mar 4, 2016
02580b0
Updated macro to upper case
Mar 4, 2016
c51e3e4
Removed Target macro define in test
Mar 4, 2016
71c2dec
Updated test cases to have SAMG55 support
Mar 4, 2016
1ed2b32
Merge branch 'master' of https://github.com/Parthasarathy/mbed
Mar 4, 2016
7c7be72
* Updated with corrections in Serial and SPI asynchronous implementat…
akhilpanayamparambil Mar 21, 2016
e6c2f1c
* Merged the changes
akhilpanayamparambil Mar 22, 2016
ba7dfa8
Used NVIC_SetVector for interrupt callback
Mar 4, 2016
9f4a29c
Removed Target macro define in test
Mar 4, 2016
dac6382
Updated test cases to have SAMG55 support
Mar 4, 2016
dbe931c
* updated with corrections in I2C Asynch implementation.
akhilpanayamparambil Mar 22, 2016
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
Prev Previous commit
Next Next commit
* updated with corrections in gpio irq.
* usticker file updated with latest source.
  • Loading branch information
akhilpanayamparambil authored and Parthasarathy.S committed Dec 18, 2015
commit 0ba8db4c7b9b84b18d3b71c851592912508b9c8b
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@

#define IRQ_RISE_POSITION 1
#define IRQ_FALL_POSITION 2
#define CHANNEL_NUM 32
#define MAX_PORT_NUM 2
#define CHANNEL_NUM 48
#define MAX_PINS_IN_PORT 32

static uint32_t channel_ids[CHANNEL_NUM] = {0};
static gpio_irq_handler irq_handler;
extern uint8_t ioinit;

static IRQn_Type pin_to_irq (uint32_t pin);

void gpio_irq_common_handler(uint32_t port_id)
{
uint32_t i = 0, status = 0, mask = 0, temp = 0;
Expand All @@ -39,7 +41,7 @@ void gpio_irq_common_handler(uint32_t port_id)
status = pio_base->PIO_ISR;
status = status & mask;

for (i = 0; i < 32 ; i++) {
for (i = 0; i < MAX_PINS_IN_PORT ; i++) {
temp = (1 << i );
if (status & temp ) {
if((pio_base->PIO_PDSR) & temp) {
Expand All @@ -48,7 +50,7 @@ void gpio_irq_common_handler(uint32_t port_id)
event = IRQ_FALL;
}
if(irq_handler) {
irq_handler(channel_ids[i], event);
irq_handler(channel_ids[(port_id * 32) + i], event);
}
}
}
Expand Down Expand Up @@ -78,11 +80,10 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
uint32_t port_id;
uint32_t vector = 0;
uint8_t int_channel = 0;
uint32_t dummyread = 0;
Pio* pio_base;

irq_handler = handler; // assuming the usage of these apis in mbed layer only
int_channel = pin % 32; /*to get the channel to be used*/
int_channel = ((pin / 32) * 32) + (pin % 32); /*to get the channel to be used*/
channel_ids[int_channel] = id;
obj->pin = pin;
port_id = ioport_pin_to_port_id(pin);
Expand All @@ -91,18 +92,18 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
ioport_set_pin_dir(pin, IOPORT_DIR_INPUT); /*Pin to be configured input for GPIO Interrupt*/
ioport_set_pin_mode(pin, IOPORT_MODE_PULLUP);

irq_n = pin_to_irq(pin);

switch (port_id) {
/*only 2 ports for SAMG55*/ /*Setting up the vectors*/
case IOPORT_PIOA :
irq_n = PIOA_IRQn;
vector = (uint32_t)gpio_irq_porta;
break;
case IOPORT_PIOB :
irq_n = PIOB_IRQn;
vector = (uint32_t)gpio_irq_portb;
break;
}
dummyread = pio_base->PIO_ISR; /*To read and clear status register*/
pio_base->PIO_ISR; /*To read and clear status register*/
NVIC_SetVector(irq_n, vector);
NVIC_EnableIRQ(irq_n);

Expand All @@ -112,7 +113,7 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
void gpio_irq_free(gpio_irq_t *obj)
{
MBED_ASSERT(obj);
channel_ids[(obj->pin) % 32] = 0;
channel_ids[((obj->pin / 32) * 32) + (obj->pin % 32)] = 0;
}

void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
Expand All @@ -137,7 +138,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
obj->irqmask &= ~IRQ_FALL_POSITION;
}
}

pio_base->PIO_ISR; /*To read and clear status register*/
if (obj->irqmask == (IRQ_RISE_POSITION | IRQ_FALL_POSITION)) { /*both edge detection*/
pio_base->PIO_AIMDR = mask;
pio_base->PIO_IER = mask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,51 @@

static uint8_t us_ticker_inited = 0;
extern uint8_t g_sys_init;
uint16_t us_ticker_16bit_counter;
uint16_t us_ticker_interrupt_counter;
uint16_t us_ticker_interrupt_offset;

#define TICKER_COUNTER_CLK ID_TC0
#define TICKER_COUNTER_uS TC0
#define TICKER_COUNTER_CHANNEL 0
#define TICKER_COUNTER_IRQn TC0_IRQn
#define TICKER_COUNTER_Handlr TC0_Handler
#define TICKER_COUNTER_uS TC0

void TICKER_COUNTER_Handlr(void)
#define TICKER_COUNTER_CLK0 ID_TC0
#define TICKER_COUNTER_CLK1 ID_TC1

#define TICKER_COUNTER_CHANNEL0 0
#define TICKER_COUNTER_IRQn0 TC0_IRQn
#define TICKER_COUNTER_Handlr0 TC0_Handler

#define TICKER_COUNTER_CHANNEL1 1
#define TICKER_COUNTER_IRQn1 TC1_IRQn
#define TICKER_COUNTER_Handlr1 TC1_Handler

#define OVERFLOW_16bit_VALUE 0xFFFF


void TICKER_COUNTER_Handlr1(void)
{
if ((tc_get_status(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL) & TC_IER_CPAS) == TC_IER_CPAS) {
us_ticker_irq_handler();
uint32_t status=tc_get_status(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL1);
uint32_t interrupmask=tc_get_interrupt_mask(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL1);

if (((status & interrupmask) & TC_IER_CPCS)) {
if(us_ticker_interrupt_counter) {
us_ticker_interrupt_counter--;
} else {
if(us_ticker_interrupt_offset) {
tc_write_rc(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL1, (uint32_t)us_ticker_interrupt_offset);
us_ticker_interrupt_offset=0;
} else
us_ticker_irq_handler();
}
}
}

void TICKER_COUNTER_Handlr0(void)
{
uint32_t status=tc_get_status(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL0);
uint32_t interrupmask=tc_get_interrupt_mask(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL0);

if (((status & interrupmask) & TC_IER_COVFS)) {
us_ticker_16bit_counter++;
}
}

Expand All @@ -42,13 +76,18 @@ void us_ticker_init(void)
if (us_ticker_inited) return;
us_ticker_inited = 1;

us_ticker_16bit_counter=0;
us_ticker_interrupt_counter=0;
us_ticker_interrupt_offset=0;

if (g_sys_init == 0) {
sysclk_init();
g_sys_init = 1;
}

/* Configure the PMC to enable the TC module. */
sysclk_enable_peripheral_clock(TICKER_COUNTER_CLK);
sysclk_enable_peripheral_clock(TICKER_COUNTER_CLK0);
sysclk_enable_peripheral_clock(TICKER_COUNTER_CLK1);

#if SAMG55
/* Enable PCK output */
Expand All @@ -57,20 +96,29 @@ void us_ticker_init(void)
pmc_enable_pck(PMC_PCK_3);
#endif

/* Init TC to waveform mode. */
tc_init(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL,
TC_CMR_TCCLKS_TIMER_CLOCK4
);
/* Init TC to Counter mode. */
tc_init(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL0, TC_CMR_TCCLKS_TIMER_CLOCK4);
tc_init(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL1, TC_CMR_TCCLKS_TIMER_CLOCK4);

NVIC_DisableIRQ(TICKER_COUNTER_IRQn0);
NVIC_SetVector(TICKER_COUNTER_IRQn0, (uint32_t)TICKER_COUNTER_Handlr0);

tc_enable_interrupt(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL0, TC_IER_COVFS);

NVIC_ClearPendingIRQ(TICKER_COUNTER_IRQn0);
NVIC_SetPriority(TICKER_COUNTER_IRQn0, 0);
NVIC_EnableIRQ(TICKER_COUNTER_IRQn0);

tc_start(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL);
tc_start(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL0);
}


uint32_t us_ticker_read()
{
if (!us_ticker_inited)
us_ticker_init();

return tc_read_cv(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL);
uint32_t counter_value=tc_read_cv(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL0);
return counter_value+(OVERFLOW_16bit_VALUE*us_ticker_16bit_counter);
}

void us_ticker_set_interrupt(timestamp_t timestamp)
Expand All @@ -86,27 +134,39 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
return;
}

NVIC_DisableIRQ(TICKER_COUNTER_IRQn);
NVIC_SetVector(TICKER_COUNTER_IRQn, (uint32_t)TICKER_COUNTER_Handlr);
uint16_t interruptat=0;

tc_enable_interrupt(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL, TC_IER_CPAS);
tc_write_ra(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL, (uint32_t)timestamp);
if(delta > OVERFLOW_16bit_VALUE) {
us_ticker_interrupt_counter= delta/OVERFLOW_16bit_VALUE;
us_ticker_interrupt_offset=delta%OVERFLOW_16bit_VALUE;
interruptat=OVERFLOW_16bit_VALUE;
} else {
us_ticker_interrupt_counter=0;
us_ticker_interrupt_offset=0;
interruptat=delta;
}

NVIC_ClearPendingIRQ(TICKER_COUNTER_IRQn);
NVIC_SetPriority(TICKER_COUNTER_IRQn, 0);
NVIC_EnableIRQ(TICKER_COUNTER_IRQn);
NVIC_DisableIRQ(TICKER_COUNTER_IRQn1);
NVIC_SetVector(TICKER_COUNTER_IRQn1, (uint32_t)TICKER_COUNTER_Handlr1);

tc_write_rc(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL1, (uint32_t)interruptat);
tc_enable_interrupt(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL1, TC_IDR_CPCS );

NVIC_ClearPendingIRQ(TICKER_COUNTER_IRQn1);
NVIC_SetPriority(TICKER_COUNTER_IRQn1, 0);
NVIC_EnableIRQ(TICKER_COUNTER_IRQn1);

tc_start(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL1);
}

void us_ticker_disable_interrupt(void)
{
tc_stop(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL);
tc_disable_interrupt(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL, TC_IER_CPAS);
NVIC_DisableIRQ(TICKER_COUNTER_IRQn);
tc_stop(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL1);
tc_disable_interrupt(TICKER_COUNTER_uS, TICKER_COUNTER_CHANNEL1, TC_IDR_CPCS);
NVIC_DisableIRQ(TICKER_COUNTER_IRQn1);
}

void us_ticker_clear_interrupt(void)
{
NVIC_ClearPendingIRQ(TICKER_COUNTER_IRQn);
}
NVIC_ClearPendingIRQ(TICKER_COUNTER_IRQn1);
}