Merge pull request #251 from 0xc0170/master

K64F - port HAL corrections, pwm clock configuration store
pull/252/head
Bogdan Marinescu 2014-04-04 10:33:01 +01:00
commit d456671126
3 changed files with 15 additions and 8 deletions

View File

@ -46,18 +46,22 @@ void port_mode(port_t *obj, PinMode mode) {
}
void port_dir(port_t *obj, PinDirection dir) {
uint32_t direction = gpio_hal_get_port_direction((uint32_t)obj->port);
switch (dir) {
case PIN_INPUT :
gpio_hal_set_port_direction((uint32_t)obj->port, kGpioDigitalInput);
direction &= ~obj->mask;
gpio_hal_set_port_direction((uint32_t)obj->port, direction);
break;
case PIN_OUTPUT:
gpio_hal_set_port_direction((uint32_t)obj->port, kGpioDigitalOutput);
direction |= obj->mask;
gpio_hal_set_port_direction((uint32_t)obj->port, direction);
break;
}
}
void port_write(port_t *obj, int value) {
gpio_hal_write_port_output((uint32_t)obj->port, (uint32_t)(value & obj->mask));
uint32_t input = gpio_hal_read_port_input((uint32_t)obj->port) & ~obj->mask;
gpio_hal_write_port_output((uint32_t)obj->port, input | (uint32_t)(value & obj->mask));
}
int port_read(port_t *obj) {

View File

@ -87,9 +87,12 @@ void pwmout_init(pwmout_t* obj, PinName pin) {
break;
}
}
pwm_clock = clkval;
uint32_t channel = pwm & 0xF;
uint32_t instance = pwm >> TPM_SHIFT;
clock_manager_set_gate(kClockModuleFTM, instance, true);
ftm_hal_set_tof_frequency(instance, 3);
ftm_hal_set_clock_ps(instance, (ftm_clock_ps_t)clkdiv);
ftm_hal_set_clock_source(instance, kClock_source_FTM_SystemClk);
ftm_hal_set_channel_edge_level(instance, channel, 2);

View File

@ -1,12 +1,12 @@
#include "test_env.h"
#if defined(TARGET_K64F)
#define P1_1 D0
#define P1_2 D1
#define P1_1 (1 << 16)
#define P1_2 (1 << 17)
#define PORT_1 PortC
#define P2_1 D7
#define P2_2 D6
#define P2_1 (1 << 2)
#define P2_2 (1 << 3)
#define PORT_2 PortC
#elif defined(TARGET_LPC11U24)
@ -18,7 +18,7 @@
#define P2_2 (1 << 25) // p1.25
#define PORT_2 Port1
#elif defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
#elif defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
#define P1_1 (1 << 9) // p0.9 -> p5
#define P1_2 (1 << 8) // p0.8 -> p6
#define PORT_1 Port0