pyFuncsInC.c File Reference

This file implements Python functions defined in main.py. More...

#include <pic24_all.h>
#include "pyToC.h"
#include "pyFuncsInC.h"
#include <pps.h>
#include <stdio.h>

Go to the source code of this file.

Defines

#define __FILE_ID__   0x70
#define OC_CONTROL_OFFSET   3
#define OC_REG(u16_reg, u16_n)   ((volatile uint16_t*) &u16_reg)[(u16_n - 1)*OC_CONTROL_OFFSET]

Functions

PmReturn_t configDigitalPinPy (pPmFrame_t *ppframe)
static PmReturn_t getPyPortPin (pPmFrame_t *ppframe, uint16_t *pu16_port, uint16_t *pu16_pin)
PmReturn_t setDigitalPinPy (pPmFrame_t *ppframe)
PmReturn_t readDigitalPinPy (pPmFrame_t *ppframe)
PmReturn_t readDigitalValuePy (pPmFrame_t *ppframe)
PmReturn_t readDigitalLatchPy (pPmFrame_t *ppframe)
PmReturn_t configAnalogPinPy (pPmFrame_t *ppframe)
static PmReturn_t readAnalogCode (pPmFrame_t *ppframe, uint16_t *pu16_analogCode)
PmReturn_t readAnalogCodePy (pPmFrame_t *ppframe)
PmReturn_t readAnalogFloatPy (pPmFrame_t *ppframe, float f_scale)
PmReturn_t configPwmPy (pPmFrame_t *ppframe)
PmReturn_t configPwm (uint32_t u32_freq, bool_t b_isTimer2, uint16_t u16_oc, int16_t i16_ocPin)
static PmReturn_t getPyOcPrn (pPmFrame_t *ppframe, uint16_t *pu16_oc, uint16_t *pu16_prn)
PmReturn_t setPwmCountsPy (pPmFrame_t *ppframe)
PmReturn_t setPwmCounts (uint16_t u16_counts, uint16_t u16_oc)
PmReturn_t setPwmRatioPy (pPmFrame_t *ppframe)
Helper functions
static PmReturn_t putPyClassInt (pPmFrame_t *ppframe, int32_t i32_val)
static PmReturn_t getPyClassInt (pPmFrame_t *ppframe, int32_t *pi32_val)


Detailed Description

This file implements Python functions defined in main.py.

Definition in file pyFuncsInC.c.


Define Documentation

#define OC_CONTROL_OFFSET   3

The offset in words between successive OC control registers. For example, &OC1RS = 0x0180 and &OC2RS = 0x0186, a three byte difference.

Definition at line 73 of file pyFuncsInC.c.

#define OC_REG ( u16_reg,
u16_n   )     ((volatile uint16_t*) &u16_reg)[(u16_n - 1)*OC_CONTROL_OFFSET]

A macro to access an Output Compare control register.

Parameters:
u16_reg Control register to set
u16_n Offset to set: the n in OCnRS, for example.

Definition at line 317 of file pyFuncsInC.c.


Function Documentation

PmReturn_t configAnalogPinPy ( pPmFrame_t ppframe  ) 

Implements the Python pic24_dspic33::analog_input::__init__ function. The configAnalogPin function does the work.

Parameters:
ppframe Python stack frame containing arguments to the function.

Definition at line 218 of file pyFuncsInC.c.

PmReturn_t configDigitalPinPy ( pPmFrame_t ppframe  ) 

Implements the Python pic24_dspic33::digital_io::__init__ function. The configDigitalPin function does the work.

Parameters:
ppframe Python stack frame containing arguments to the function.

Definition at line 76 of file pyFuncsInC.c.

PmReturn_t configPwm ( uint32_t  u32_freq,
bool_t  b_isTimer2,
uint16_t  u16_oc,
int16_t  i16_ocPin 
)

Configure an output compare module for PWM operation.

Parameters:
u32_freq Frequency at which the PWM will operate, in Hz.
b_isTimer2 True to use timer2, false to use timer3 for PWM.
u16_oc Output compare module to use.
i16_ocPin For remappable devices, the port P pin on which to map the PWM output. For non-remappable devices, this value must be < 0.

Definition at line 321 of file pyFuncsInC.c.

PmReturn_t configPwmPy ( pPmFrame_t ppframe  ) 

Implements the Python pic24_dspic33::pwm::__init__ function. The configPwm function does the work.

Parameters:
ppframe Python stack frame containing arguments to the function.

Definition at line 288 of file pyFuncsInC.c.

static PmReturn_t getPyClassInt ( pPmFrame_t ppframe,
int32_t pi32_val 
) [static]

Get an int of private data from a Python class.

Parameters:
ppframe Stack frame containing Python arguments. Argument 0 should be the object.
pi32_val An int stored in the class is returned here.

Definition at line 49 of file pyFuncsInC.c.

static PmReturn_t getPyOcPrn ( pPmFrame_t ppframe,
uint16_t pu16_oc,
uint16_t pu16_prn 
) [static]

Get the PR2/3 value and the OC peripheral in use from the Python PWM object.

Parameters:
ppframe Stack frame containing Python arguments. Argument 0 should be the object.
pu16_oc Output compare module to use.
pu16_prn The value of the PR2/3 register. The register passed is based on which timer (Timer 2 or 3) the OC module was configured to use.

Definition at line 417 of file pyFuncsInC.c.

static PmReturn_t getPyPortPin ( pPmFrame_t ppframe,
uint16_t pu16_port,
uint16_t pu16_pin 
) [static]

Get the port and pin from a digital I/O object.

Parameters:
ppframe Stack frame containing Python arguments. Argument 0 should be the object.
pu16_port The port number taken from the object is stored here.
pu16_pin The pin number taken from the object is stored here.

Definition at line 117 of file pyFuncsInC.c.

static PmReturn_t putPyClassInt ( pPmFrame_t ppframe,
int32_t  i32_val 
) [static]

Store an int of private data to a Python class.

Parameters:
ppframe Stack frame containing Python arguments. Argument 0 should be the object.
i32_val An int to store in the class.

Definition at line 22 of file pyFuncsInC.c.

static PmReturn_t readAnalogCode ( pPmFrame_t ppframe,
uint16_t pu16_analogCode 
) [static]

Read an analog code from the ADC and return it.

Parameters:
ppframe Stack frame of Python arguments passed to the function
pu16_analogCode Code read from the ADC.

Definition at line 242 of file pyFuncsInC.c.

PmReturn_t readAnalogCodePy ( pPmFrame_t ppframe  ) 

Implements the Python pic24_dspic33::analog_input::getCode function.

Parameters:
ppframe Python stack frame containing arguments to the function.

Definition at line 262 of file pyFuncsInC.c.

PmReturn_t readAnalogFloatPy ( pPmFrame_t ppframe,
float  f_scale 
)

Implements the Python pic24_dspic33::analog_input::getVoltage function.

Parameters:
ppframe Python stack frame containing arguments to the function.
f_scale Scale factor to multiply the code by before returning a value.

Definition at line 275 of file pyFuncsInC.c.

PmReturn_t readDigitalLatchPy ( pPmFrame_t ppframe  ) 

Implements the Python pic24_dspic33::digital_io::getLatch function. The readDigitalLatch function does the work.

Parameters:
ppframe Python stack frame containing arguments to the function.

Definition at line 198 of file pyFuncsInC.c.

PmReturn_t readDigitalPinPy ( pPmFrame_t ppframe  ) 

Implements the Python pic24_dspic33::digital_io::getPin function. The readDigitalPin function does the work.

Parameters:
ppframe Python stack frame containing arguments to the function.

Definition at line 151 of file pyFuncsInC.c.

PmReturn_t readDigitalValuePy ( pPmFrame_t ppframe  ) 

Implements the Python pic24_dspic33::digital_io::get function.

Parameters:
ppframe Python stack frame containing arguments to the function.

Definition at line 171 of file pyFuncsInC.c.

PmReturn_t setDigitalPinPy ( pPmFrame_t ppframe  ) 

Implements the Python pic24_dspic33::digital_io::set function. The setDigitalPin function does the work.

Parameters:
ppframe Python stack frame containing arguments to the function.

Definition at line 130 of file pyFuncsInC.c.

PmReturn_t setPwmCounts ( uint16_t  u16_counts,
uint16_t  u16_oc 
)

Set the duty cycle of the PWM peripheral.

Parameters:
u16_counts A number of PR2/3 counts which gives the on time of the PWM wave to generate. Must be less than the PR2/3 value.
u16_oc Output compare module to use.

Definition at line 446 of file pyFuncsInC.c.

PmReturn_t setPwmCountsPy ( pPmFrame_t ppframe  ) 

Implements the Python pic24_dspic33::pwm::setCounts function. The setPwmCounts function does the work.

Parameters:
ppframe Python stack frame containing arguments to the function.

Definition at line 430 of file pyFuncsInC.c.

PmReturn_t setPwmRatioPy ( pPmFrame_t ppframe  ) 

Implements the Python pic24_dspic33::pwm::set function.

Parameters:
ppframe Python stack frame containing arguments to the function.

Definition at line 457 of file pyFuncsInC.c.


Generated on Mon Oct 18 07:40:48 2010 for Python-on-a-chip by  doxygen 1.5.9