Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Development #3

Merged
merged 8 commits into from
Feb 17, 2017
Merged
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
163 changes: 0 additions & 163 deletions cores/arduino/HardwareSPI.h

This file was deleted.

4 changes: 4 additions & 0 deletions cores/arduino/HardwareTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ void HardwareTimer::attachInterrupt(int channel, voidFuncPtr handler) {
timer_attach_interrupt(this->dev, (uint8)channel, handler);
}

void HardwareTimer::toneAttachInterrupt(int channel, voidFuncPtr handler) {
tone_attach_interrupt(this->dev, (uint8)channel, handler);
}

void HardwareTimer::detachInterrupt(int channel) {
timer_detach_interrupt(this->dev, (uint8)channel);
}
Expand Down
1 change: 1 addition & 0 deletions cores/arduino/HardwareTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ class HardwareTimer {
* @see voidFuncPtr
*/
void attachInterrupt(int channel, voidFuncPtr handler);
void toneAttachInterrupt(int channel, voidFuncPtr handler); // alfran : used for tone

/**
* @brief Remove the interrupt handler attached to the given
Expand Down
2 changes: 1 addition & 1 deletion cores/arduino/HardwareSPI.cpp → cores/arduino/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extern "C" {

}

#include "HardwareSPI.h"
#include "SPI.h"
SPIClass SPI;

SPI_HandleTypeDef hSPIx;
Expand Down
20 changes: 13 additions & 7 deletions cores/arduino/Tone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Version Modified By Date Comments

volatile static int toggle_count=0;
static int tone_pin;
int timer_CH = 2;
int timer_CH = 5;

HardwareTimer timer(timer_CH);

Expand All @@ -55,7 +55,7 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration)
timer.setOverflow(1000000/frequency/4);
timer.setMode(TIMER_CH1, TIMER_OUTPUT_COMPARE);
timer.setCompare(TIMER_CH1, 1); // Interrupt 1 count after each update
timer.attachInterrupt(TIMER_CH1, handler_tone);
timer.toneAttachInterrupt(TIMER_CH1, handler_tone);
timer.refresh(); // start it up
timer.resume();

Expand All @@ -66,17 +66,23 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration)
void noTone(uint8_t pin)
{
timer.pause();
gpio_write_bit(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, 0);

return;
timer.setPrescaleFactor(1);
timer.setOverflow(0xFFFF);
timer.setMode(TIMER_CH1, TIMER_PWM);
timer.refresh();
timer.resume();
gpio_write_bit(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, 0);
pinMode(pin,INPUT); //to fix dfu issue

return;
}

/*
void set_timer(int ch)
{
HardwareTimer timer(ch);
timer_CH = ch;
}

*/
void handler_tone(void)
{
if (toggle_count != 0){
Expand Down
3 changes: 2 additions & 1 deletion cores/arduino/pwm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void analogWrite(uint8 pin, uint16 passed_val)
timer_dev *dev = PIN_MAP[pin].timer_device;
if (pin >= GPIO_PINS || dev == NULL || dev->type == TIMER_BASIC)
{
return;
return;
}
if (PIN_MAP[pin].alternate_function != AFx)
{
Expand All @@ -76,6 +76,7 @@ void analogWrite(uint8 pin, uint16 passed_val)
timer_set_compare(dev, PIN_MAP[pin].timer_channel, duty_cycle);
timer_cc_enable(dev, PIN_MAP[pin].timer_channel);
gpio_set_mode(PIN_MAP[pin].gpio_device, PIN_MAP[pin].gpio_bit, GPIO_AF_OUTPUT_PP);

}
}

Expand Down
Loading